Searching for files in specific folders

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Rory
Pro Scripter
Posts: 50
Joined: Thu Mar 23, 2006 2:50 pm
Location: Wisconsin

Searching for files in specific folders

Post by Rory » Tue Apr 19, 2011 12:20 am

Is there a way to automate searching multiple specific folders rather than searching My Computer?
Say you have three different folders each on a separate network drive. Is it possible to key in the file name once that you are looking for and see the results sorted by the folder they are contained in? Searching the whole network takes time where specific folders return results faster.

Thanks,
Rory

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Apr 19, 2011 12:30 pm

Is there a way to automate searching multiple specific folders rather than searching My Computer?
The quick answer is yes. But it requires programming this.

One method would be to issue the DOS command

dir {file spec} /S >outputfile.txt

in each of the respective folders

and then parse the outputfile.txt to see if you have any hits.

It is possible to make these searches occur in parallel to make it even faster.

The first "dir" command creates outputfile.txt because of the single ">"
redirection. Subsequent commands can specify ">>" and this will append to the the existing file.

Hope this gives you some ideas where to start.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Apr 19, 2011 3:31 pm

Here is a simple sample which works for me.

Code: Select all

Let>Folder1=c:
Let>Folder2=x:
Let>Folder3=I:\TestDeliverables

Let>FileSpec=setup.log


Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Let>RP_DISPLAYERROR=1
RunProgram>cmd /c  dir %Folder1%\%FileSpec% /s  >c:\searchresult.txt
RunProgram>cmd /c dir %Folder2%\%FileSpec% /s  >>c:\searchresult.txt
RunProgram>cmd /c dir %Folder3%\%FileSpec% /s >>c:\searchresult.txt

ReadFile>c:\searchresult.txt,result
MessageModal>result

Rory
Pro Scripter
Posts: 50
Joined: Thu Mar 23, 2006 2:50 pm
Location: Wisconsin

Post by Rory » Wed Apr 20, 2011 2:10 am

Thanks for the help.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts