Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Is there an easy way to copy a file if it contains a text string

Do you mean something like this?

Code:
ffind /t"text string" file > nul
if %_? == 0 copy file ...

On one line

Code:
if %@exec[ffind /t"text string" file > nul] == 0 copy file ...
 
Yeah, that should work if I put it in a For loop so I can copy all the files in a directory that contain the text string. Thanks! :) I'll give it a try and let you know.
 
If the goal is to copy a bunch of files then an easier solution would be be to use the file names that ffind spits out.
Code:
do f in /p ffind /b /c /t"text string" * (copy %f ...)
You can create an alias for that or a function.
Code:
alias tcopy=`do f in /p ffind /b /c /t%1 %2 (copy %f %3)`
tcopy "test string" * dest_folder
 
Thanks guys! Excellent advice! I just used the do f etc to find and copy all the PDFs created by a particular user to find the one he said had an incorrect format. It was a lot easier to open up 11 PDFs rather than several hundred. Of course I could have just used the windows explorer search function for that, but next I plan on using it in a script to automatically find logs with certain errors in our printing software.
 
Back
Top