Directory search

i have created a method which lists a directory of folders sub folders and files. It outputs them into a file. At the moment it only lists files, folders and subfolders, it doesnt go deeper than a subfolder so if there is a folder within that subfolder it will be ignored.
Essentially i want the method to recursively list all files within any folders in a directory. Also i i think it would be more efficient to output the file names into a array of strings.
try
        PrintWriter out2 = new PrintWriter(new BufferedWriter(new FileWriter(outFile2)));
        PrintWriter out3 = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));
        status.setText("Searching " + searchDir.substring(searchDir.length()));
        File f = new File(searchDir);
        //List directory
        if(f.isDirectory())
            String w[] = f.list();
            for (int i=0; i<w.length; i++)
               if(w.indexOf(".txt") <= 0)
File dir1 = new File("c:/me/"+w[i]+"/");
if(dir1.isDirectory())
String z[] = dir1.list();
for (int j=0; j<z.length; j++)
{         if(z[j]!="")
out2.println(w[i]+"/"+z[j]);
System.out.println(w[i]+"/"+z[j]);
else
{ System.out.println("it works");
break;
if(w[i].indexOf(".txt") >= 0)
//if((w[i].indexOf(".txt") >= 0)||(w[i].indexOf(".gif") >= 0)||(w[i].indexOf(".jpg") >= 0))
out2.println(w[i]);
out2.close();
catch(IOException e)
System.out.println("Input file does not exist or some other errors");
The program searches through files for a users input so i need to do this for all files in a specific directory.
Has anyone got any suggestions on how i can improve this method or the best way to do it.

or you could use a File Filter
public class MyFileFilter implements java.io.FileFilter {
    private String[] ext;
    public MyFileFilter() {
    //takes an array of file extensions
    public MyFileFilter(String[] ext) {
        this.ext = ext;
    public boolean accept(java.io.File file) {
        if(file.isDirectory())
            return true;
        else if(ext==null&&file.exists())
            return true;
        else
            for(int i=0;i<ext.length;i++)
                if(file!=null&&file.exists()&&file.getName().indexOf(ext)>0)
return true;
return false;
then create a filter
filter = new MyFileFilter(new String[]{".gif",".jpg"});then send it to a recursive method
    public static ArrayList getFiles(File parent, FileFilter filter) {
        ArrayList current = new ArrayList();
        if(parent!=null&&filter!=null) {
            File[] files = parent.listFiles(filter);
            if(files!=null)
                for(int i=0;i<files.length;i++) {
                    if(files.isDirectory())
current.addAll(getFiles(files[i], filter));
else
current.add(files[i]);
return current;
then traverse arraylist and write the toString() or getName() or whatever
walker

Similar Messages

  • I installed PP6 on my Lenovo Laptap with Win8.1. Worked fine. Turned off computer. Turned back on. Can not open ANY PP6 program.  No Adobe app shows as a listed program to uninstall.  However, Adobe PP6 files shows in directory search.  How do I fix?

    How do you uninstall PP6 with win8.1 when it no longer shows up as a program listed with an uninstall options.  PP  worked until I turned off computer and restarted.  All start up links are gone.   I can see where Adobe PP6 files installed when I do a directory search but no .exe start files in those directories work.  I can not uninstall PP6 and try again to re-install.    How do I fix this problem?

    Thanks Michael. Apologies for the slow reply I was away for a bit (holiday blitz at work and visiting family madness etc.etc.) back now, I set both options you requested to "never " and retried the CMS software with no change. 
    I do have progress of a sort though, as a test I took a separate test PC and put a clean install of Win7 on and loaded up the CMS software (it worked perfectly) and then took the version of ole32.dll off that machine and put it onto the computer I had built
    for her (using Linux) and...
    got a new error code. Darn I was so sure I had found a clever solution this time lol.
    Anyway now when the CMS fails it gives me a similar error but the offending module is "ntdll.dll" sooo... I tried taking the "working" version of ntdll.dll from the test box and moving it over (making sure to back up the existing ones
    first so I could put them back if needed) to her new PC and the PC would not boot. 
    It seems to want the original versions of a few Dynamic Link Libraries and if I could somehow give it those while not breaking Win7 it should theoretically work seeing as it no longer errors with ole32.dll. 
    ntdll.dll however seems necessary for Win7 to boot.
    So what I am wondering now is:
    Is there some way to have both versions of the DLL file in the system32 folder (bypassing the "cannot have two files with the exact same name in the same folder" thing) or rename the original DLL's something else and somehow make the CMS look for
    the new named versions so the system has the updated DLL's it needs to boot/run and the CMS has the old ones it wants to run or is there someway to have a self contained install of the CMS, say on a USB flash drive and give it it's own E:/windows/system32/needed
    dll's  path to the files it needs? 
    Willing to try any other options or settings you may have come up with as well.
    Thanks again for your reply and my apologies for not answering sooner.

  • Xfce4 Groups Not in the Package Directory Search?

    This is probably a stupid question, but how are people supposed to know that they can do things like:
    # pacman -S xfce4
    # pacman -S xfce4-goodies
    when neither of those two groups show up in the Package Directory Search?  I'm installing Arch for the first time and only found that information from the Wiki.  Is there something obvious I'm missing?

    Thank you...I hadn't thought to look there.  Don't you think it would be nice to put the group listing on the web interface as well?

  • IronPort Security Management Appliance - Directory Search Results Size

    I'm creating an access policy for a web security appliance that is applied to an authorized group within an idenity.  My question is in regards to the number of returned results when using the Directory search function to find and add the group.  Only the first 500 matching entries are shown and attempting to search for the group fails if it isn't part of that first 500.  How do I increase the amount of results returned when searching for groups?

    Hello Alex,
    By default, Active Directory does not respond to LDAP based queries which return more than 1000 results. If you have more than 1000 groups configured in Active Directory, it is necessary to increase the maximum page size (MaxPageSize) using the Ntdsutil.exe tool.
    http://support.microsoft.com/default.aspx?scid=kb;en-us;315071&sd=tech
    MaxPageSize - This value controls the maximum number of objects that are returned in a single search result, independent of how large each returned object is. To perform a search where the result might exceed this number of objects, the client must specify the paged search control. This is to group the returned results in groups that are no larger than the MaxPageSize value. To summarize, MaxPageSize controls the number of objects that are returned in a single search result.
    Default value: 1,000
    You can also simply input the group name and then click "Add" to manually add it as a workaround.
    Hope it helps.

  • Exchange directory search

    I've got my iPhone connected properly to my work Exchange Server (2003).
    One thing I've noticed though is the directory search doesn't seem to function properly. If I search for a persons first or last name it doesn't find them. But if I put in first initial last initial it'll bring up a list of users.
    Has anyone come across this problem?
    For instance if John Doe is in the directory, the following wont find them:
    John
    Doe
    But the following will find them:
    J D

    I have Exchange 2007. I just did a test on my first gen iPhone running the new 2.0 firmware. I searched by first name, last name and user name. All 3 worked as expected.
    I do notice that I dont see much info on the selected user. For example, when I look for myself in the GAL I see my email address, my office phone number and my job title, but part of the company field is cut off (truncated). Not sure if this is server side filters or not.
    Message was edited by: Daniel Stranathan

  • PS Directory.Searcher for searching AD - inconsistent results?

    Hi guys,
    I'm having problems with a script and need some assistance please. I needed a script to search all the users in my AD and return some information around passwords. I found a few blogs about searching AD for user information, so using that help I cobbled
    together a script to return the information I need.
    Here's the script:-
    cls
    $Domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
    $DomainRootPath = [ADSI]"LDAP://$Domain"
    $adsearch = New-Object DirectoryServices.DirectorySearcher([adsi]$DomainRootPath)
    #$adsearch.filter = "(objectclass=user)"
    $adsearch.Filter = "(&(objectCategory=person)(objectClass=user))"
    $adsearch.PropertiesToLoad.AddRange(@("name"))
    $adsearch.PropertiesToLoad.AddRange(@("lastlogontimestamp"))
    $adsearch.PropertiesToLoad.AddRange(@("givenName"))
    $adsearch.PropertiesToLoad.AddRange(@("SN"))
    $adsearch.PropertiesToLoad.AddRange(@("DisplayName"))
    $adsearch.PropertiesToLoad.AddRange(@("pwdLastSet"))
    $adsearch.PropertiesToLoad.AddRange(@("description"))
    $adsearch.PropertiesToLoad.AddRange(@("userAccountControl"))
    $adsearch.Container
    $adsearch.PageSize = 1000
    $adsearch.SearchScope = "Subtree"
    $users = $adsearch.findall()
    $users.Count
    $report = @()
    foreach ($objResult in $users)
    $objItem = $objResult.Properties
    $llt = $objItem.lastlogontimestamp
    $pls = $objItem.pwdlastset
    If (!$pls)
    $plsDate = "--Never Reset Pwd--"
    $PassLastSet = $plsDate
    Else
    # Interpret 64-bit integer as a date.
    $plsDate = $pls = [DateTime]$objItem.pwdlastset.item(0)
    $PassLastSet = $plsDate.AddYears(1600).ToLocalTime()
    If (!$llt)
    $lltDate = "--Never Logged In--"
    $lastLogon = $lltDate
    Else
    # Interpret 64-bit integer as a date.
    $lltDate = $llt = [DateTime]$objItem.lastlogontimestamp.item(0)
    $lastLogon = $lltDate.AddYears(1600).ToLocalTime()
    $temp = New-Object PSObject
    $temp | Add-Member NoteProperty name $($objitem.name)
    $temp | Add-Member NoteProperty lastlogontimestamp $lastLogon
    $temp | Add-Member NoteProperty pwdLastSet $PassLastSet
    #$temp | Add-Member NoteProperty displayname $($objitem.displayname)
    $temp | Add-Member NoteProperty useraccountcontrol $($objitem.useraccountcontrol)
    #$temp | Add-Member NoteProperty givenname $($objitem.givenname)
    #$temp | Add-Member NoteProperty sn $($objitem.sn)
    $temp | Add-Member NoteProperty comment $($objitem.description)
    $report += $temp
    $datetime = Get-Date -format yyyy.MM.dd-HH.mm.ss
    $csvpath = "C:\powershell logs\"
    $csvfile = "$csvpath\$datetime-userlist.csv"
    $report | export-csv -notypeinformation $csvfile
    My problem is some results are missing for some users. I only have around 200 users and many return a complete set of results. But many users don't return a result for lastlogontimestamp, pwdLastSet or userAccountControl - the three fields that aren't strings...
    I'm not sure if this is necessarily a powershell problem (perhaps my AD is corrupt or something weird like that?). When I query the $users array these fields are missing for the users - but when I use the ADSi edit GUI I can see there is data in these fields.
    It seems like the Directory.Searcher might have a bug or something?
    Apologies if there's a more appropriate place to post this please let me know - any help would be greatly appreciated!!
    Many thanks,
    Rob
    :D

    But I believe I provide an apples to apples comparison earlier, perhaps you missed it?
    Here's the gist from the post, but the entire post might be worth reading if you did miss it..
    Here's an example of a problem user account. To simplify things I'm using the results from your GetUserADProperties.ps1 script.
    Script results:
    Name = User A
    pwsLastSet = NULL (Blank, no result)
    lastlogontimestamp = NULL (Blank, no result)
    ADSI Edit GUI results:
    Attribute: Name       Value: User A         Syntax: Unicode String
    Attribute: lastlogontimestamp       Value: 04/01/2012 10:23:21 Coordinated Universal Time         Syntax: Large Integer/Interval
    If I double-click a box pops up with the Value: 129701462019825126
    Attribute: pwdLastSet       Value: 04/01/2012 11:30:44 Coordinated Universal Time         Syntax: Large Integer/Interval
    If I double-click a box pops up with the Value: 129701502443598094
    If this isn't an apples to apples comparison  how can I provide one?
    :D
    You should not be using ADSIEDit.  Use ADUC with the acctinfo.dll extension.
    The Large Integer value is the timestamp - it may be set to a value that indicate that it has not been set.
    ADSIEdit is not necessarily a live view of AD objects.  It is an editor for raw objects and it is very easy to break AD with it.
    If yu have been  using it regularly then perhps this explains why you have issues with AD.
    Is this a corporate AD implementation?
    Is this AD 2003/2008 or R2?
    Is this just a home test rig?
    If WS2003 then what level is it at?
    Somewhere in the above is the reason you are seeing issues.  Everything you ae providing just points to some bits of missing information. The scripts are working correctly.  The results from adsiedit may not be what they seem.
    jv

  • Jabber IM for iPhone and corporate directory search

    Hello!
    In the Administrator's Guide (http://www.cisco.com/en/US/docs/voice_ip_comm/jabber/iPhone/8.6/Cisco_Jabber_IM_for_iPhone_Admin.pdf)
    I cannot  find an example of how configuring the client to search in the corporate  directory, or the
    requirements to do this. I don't understand how it  works, in Cisco Jabber for Windows we configured UDS to search into CUCM  directory, but it was also possible to use a external LDAP.
    I tried also to configure a LDAP Profile in CUPS, and to associate the user to this profile but Jabber IM cannot find any contacts.
    CUPS 8.6(3), Cisco Jabber IM 1.0.0
    Regards,
    Mirko

    Jabber IM for iPhone use the LDAP profile configurable on the CUPS Admin page,  Application->Cisco Jabber->LDAP Profile.
    At first you have to configure your LDAP Server (Application->Cisco Jabber->LDAP Server): add here the  IP Address of the LDAP  Server with port 3268 and protocol type TCP, when you don't need to use  LDAPS.
    After that configure the LDAP profile and associate the user to this profile: you can  do this either in the user setting page (Application->Cisco Jabber->User  Setting) or directly on the LDAP Profile page.

  • Interface mapping not shown in directory search help

    Hi,
    I creatd a interface mapping in repository with message mapping. but when i configure the directory for receiver determination .. the interface mapping is not shown when i click the search help.
    pls any one help me .
    thankx,
    shree

    Hi Shree,
    Three checkpoints:
    1. Make sure you have entered the correct outbound and inbound interfaces.
    2. Make sure you have activated your interfaces and mappings.
    3. Make sure the cache is up-to-date (you can refresh cache by transaction sxi_cache).
    Hope this helps.
    Regards,
    Hart

  • Directory search returns wrong results when you modify the view

    Hello,
    I have a custom list used a staff directory.  This is SharePoint 2013.  I am using a search box where users can type in names to find people. 
    When I add or remove a record in the list or modify the view and then I search for my name, all search results appear.  It once just returned 1 record for my name, but now it returns all 100 records in the list.
    How can I fix this?
    Thanks,
    Paul
    Paul

    Hi Paul,
    Did you search in the SharePoint list or in SharePoint search center?
    Could you provide more details about how you created the custom list?
    Please try to enable Server Render as editing the page->Edit Web Part-> Miscellaneous, compare the result.
    Please operate in other lists and in other site collections and test whether this issue occurs.
    Please start a full crawl in Central Administration -> Manage service application -> Search service application -> Content Sources and test whether this issue occurs.
    Could you check if it exists error in ULS log after you failed to search in the SharePoint list.
    Best Regards,
    Dean Wang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Skype vs Skype for Business Directory Search

    Our company uses Office 365 and recently the Lync option was converted to Skype for Business which wasn't very hard for our company to adjust to even with the sudden change. But we have been wanting to use the Skype for Business to conduct mettings with Skype Users. After doing research to find instructions for adding a Skype User to Skype for Business I found out we need the Skype Directory selection beside My Contacts when searching a User. My problem is when I start typing in a Skype User only the My Contacts tab is displayed and no Skype Directory tab. How can I get this functionality enabled or when will this functionality be working?

    WGordon wrote:
    Our company uses Office 365 and recently the Lync option was converted to Skype for Business which wasn't very hard for our company to adjust to even with the sudden change. But we have been wanting to use the Skype for Business to conduct mettings with Skype Users. After doing research to find instructions for adding a Skype User to Skype for Business I found out we need the Skype Directory selection beside My Contacts when searching a User. My problem is when I start typing in a Skype User only the My Contacts tab is displayed and no Skype Directory tab. How can I get this functionality enabled or when will this functionality be working?Did you ever get a resolution?

  • Directory search using APEX

    Hi,
    I have a requirement that there is a directory tree and the group of files are present in each directory under its parent. I have to make a search application that will find the files with its corresponding path where it is present(like desktop application search). Is it possible using APEX? or shall I choose some other application. Please suggest.
    Regards,
    Kaushik

    You can do it, but getting directory contents into your database in order to present it in APEX may not be the best use case.
    See http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:439619916584

  • Cisco CM users can't dial after Directory Search

    Cisco Call Manager 4.1.2
    Users who use the Corporate Directory to search for other users, cannot dial a any users after a search. Extension numbers associated to the searched user do not show up as well. I know other versions of Call Manager this just worked out of the box. Is there something I need to configure?
    Nothing happens, no reorder tone nothing it does not dial.
    Anyone any ideas?

    this replay only for the record if someone face same issue, bcz i think it solved for you by now
    make sure that you add the directory number ( DN) extension in the user itself at the place called telephone number
    user managment--> End user --> user X --> user information and write down the DN at telphone number

  • Document Directory search format

    The Document Directory/Knowledge Directory can search files. Does it actually search file content orfile properties orboth?
    In other words, where does this data come from: PT_PROPERTY_CARDSUMMARY
    and where is it stored in teh database?

    Unfortunately, the existing XML elements do not permit dynamic partial updates so you cannot do that.

  • Windows 7 - Slow directory searches

    I have a Windows 7 Pro machine that occasionally will have Microsoft Office programs, AutoDesk programs that will take a few seconds to jump from directory to directory and show not responding at the tops. Finally after 30 seconds or so, the directory listing will show up.
    I had the latest Client SP3 IR4 installed then back rev'd hoping it was the cause but did not help. We do have file cache off in the client because we were having Microsoft Access Database issues.
    We do have several other Window 7 machines but they dont experience the delays all the time like this one.
    Is there another setting that needs to be changed?
    Thanks in advance,
    Ken

    Hi Ken,
    Perhaps take a look at this TID: Support | Slow performance when browsing directories and copying files residing on a server
    There are some Windows tweaks and take a look at the Microsoft KB article: Slow data transfer speed in Windows 7 or in Windows Server 2008 R2
    Let us know how it goes.
    Cheers,

  • Directory Search  using FilenameFilter

    I have a directory that has over 100,000 files in the following format:
    Invoice-100010001-16072007.xls
    Invoice-100010001-16072007.pdf
    I want to be able to find all files with a certain name (ie Invoice-100010001).
    Is it possible to use a FilenameFilter to implement this?

    I was just concern about the timing/perfomance. In
    the list method, is it a loop through all the files
    in the directory? Wouldn't this be a problem if I
    have over 10000 files?Probably since Java loads all the files/directories index items and then filters them.

Maybe you are looking for

  • Module integration

    hello, I want to know the accounting entry of finished goods after pp: the following entries are- 1. On completion of production confirmation the following entry is passed      Finished goods stock A/c               Dr      Cost of goods produced    

  • Document Name & Download file Link should display together

    Dear Friends, i am working with apex_3.2 . i have created form with report on forms i have displayed 5 file browser item. in report these 5 document file display as a download link in report.- i want to display document name Download link together in

  • Plz tell me about in bdc source table to target table covertion

    hi, this is kalyan how can we transfer the data from source to target

  • Remove error during impdp

    Hi, How to remove error during import using impdp. ORA-39082: Object type PACKAGE_BODY:"JISPBILCORBILLINGTST502"."COR_BILL" created with compilation warnings ORA-39082: Object type VIEW:"JISPBILCORBILLINGTST502"."VWACTUALUNBILLEDUSAGE_CDR" created wi

  • Trouble when a project name starts with ´@´.

    I have a trouble when a project name starts with ´@´. I can´t watch any photo into the aperture browser. Is that a bug? Any help please? Thanks in advance.