Find in Files across multiple root directories

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
dasfenster
Posts: 4
Joined: Thu Dec 02, 2004 4:50 pm
Location: Cambridge, MA

Find in Files across multiple root directories

Post by dasfenster »

Is there any way to do a "Find in Files" across multiple directory roots?

For example, looking for the string "foo" in C:\files and D:\files

The "in folder" text box does not seem to like multiple paths. I tried delimiting them with commas, semi-colons, and spaces but with no luck.
User avatar
s_reynisson
Posts: 940
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

Found this in TP's help file, hope it helps.
In the In Files box, either type a space separated list of wild cards, or choose a previous list from the drop-down list. Note that by creating a file containing a list of file names, one per line, and specifying the name of that file in this box, preceded by the character '@', this command will search the specified files.
So

Code: Select all

Find what: yourString
In files: @filelist.txt
In folder: E:\test\
Where filelist.txt is in E:\test, in my case it contains just two lines:

Code: Select all

E:\test\temp.txt
C:\test\temp.txt
TP returns both files in the search results window, only drawback is you have to manually create the list of files.
Then I open up and see
the person fumbling here is me
a different way to be
dasfenster
Posts: 4
Joined: Thu Dec 02, 2004 4:50 pm
Location: Cambridge, MA

not quite there

Post by dasfenster »

thanks for your help but I should have explained the problem with a little more detail. Unfortunately using the @filelist.txt technique doesn't allow for wildcards in the file. So using your example, I am unable to do the following:

Code:
Find what: yourString
In files: @filelist.txt
In folder: E:\test\

Where filelist.txt is in E:\test, in my case it contains just two lines:
Code:
E:\test\*.txt
C:\test\*.txt

It seems that you need to put literal filenames in filelist.txt which is not really an option for me because I can't count on how many .txt files there are in those directories..or their exact prefixes for that matter.

Any other options?

-Thanks

steve
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Could this work for you?

you could do a redirected DIR listing to make the file list, and not need wild cards:

Dir C:\test\*.txt >>E:\test\filelist.txt
Dir E:\test\*.txt >>E:\test\filelist.txt
Hope this was helpful.............good luck,
Bob
dasfenster
Posts: 4
Joined: Thu Dec 02, 2004 4:50 pm
Location: Cambridge, MA

Post by dasfenster »

Thanks but it's not really a desirable option for me. It would be too many extra steps that i'd have to take across many directory roots, each of which could have hundreds of files in them. I also need to use unc paths because the directories live on multiple servers.

my directory list would look something like this:

\\server1\logs\*.txt
\\server2\logs\*.txt
...
\\server20\logs\*.txt

the name and the number of files represented by the * in *.txt is variable
VSLEWIS
Posts: 15
Joined: Tue Nov 30, 2004 10:18 pm
Location: Phoenix AZ

search across multiple dir

Post by VSLEWIS »

TP will only (to my knowledge and experience) search a specific directory. You should be able to run "find" (UNIX, WIN-NT) as a batch script searching for your 'string' as a parameter, then pipe the results to a file. Then create a macro that reads a line in a file and opens that file.
___________________________________
THX
Lewis Schwartz
LSCHWARTZ@MAIL.MARICOPA.GOV
TP - Where would I be w/o it??
___________________________________
dasfenster
Posts: 4
Joined: Thu Dec 02, 2004 4:50 pm
Location: Cambridge, MA

Post by dasfenster »

Thanks VSLEWIS...I pretty much ended up writing a little find batch utility to do what you said. I've never done anything with TP macros before. Would someone be willing to give me a pointer or two?

My'findstr' results file looks something like this:

\\machine1\share\foo1.txt: <string i was searching for>
\\machine1\share\foo2.txt: <string i was searching for>
\\machine2\share\foo2.txt: <string i was searching for>
\\machine3\share\foo3.txt: <string i was searching for>
etc...

So if i pull this results file into TP, can a macro be made to open the file and go to that specific line in the file....just like when you click on a line in the TP search results window?
charles
Posts: 20
Joined: Mon Dec 27, 2004 5:11 pm
Contact:

File List

Post by charles »

Very helpful, I didn't know TP could do that ...
Post Reply