|
Answer» Hi all,
I need HELP setting the filename and path, for a secondary search. Scenario is this;
I've done a search of all drives for files of a certain size, and echoed the results to text (showing full path). I now need to search the files in those results for a string. How do I echo those to the command line with my search parameters?
I have another situation where I have done a specific directory search of all drives, and now need to echo those paths back to get a file list in each directory.
Intent is to use on 9X and NT both.
TIA Assuming z.txt contains a list of filenames, and z.lst is where you want your results:
Code: [Select]echo off time /t>z.lst for /f %%i in (z.txt) do ( find "Press Enter" %%i >> z.lst 2>&1 ) Thanks QBasicMac. That helped a lot. I had to revise it a bit due to the fact that I forgot to add, that also in the text is the file size, currently listed first (all the same size). Have it working for NT using ' for /F "tokens=2" %%i '. Would using the %%i as SHOWN above work for 9X if filepath was listed first and size second? Or, is there a way I can MAKE it ignore or even retype the list without the file size, then use the ' for /F %%i ' ?
TIA
BTW, what does this do? 2>&1 dir /b That will avoid DATE/time, etc.
2>&1 says to write any error messages to the same place as the regular messages.
example, if you say type abc.txt then abc.txt will be typed to the console, right? and if there is no file abc.txt, an error message instead.
If you say type abc.txt >mylog.txt then abc.txt will be type to mylog.txt. But if there is no file abc.txt then an error message will be typed to the console, not abc.txt.
But if you say type abc.txt >mylog.txt 2>&1 both will go to mylog.txt.
2> is for errors 1> is normal (nobody ever types the "1" but they could)
Mac Uh, yep, the tokens stuff should work if you can't avoid the date. What exactly did you use to build the list?
I know of no way to get files smaller than x, such as
dir *.* /size<5K /b /s >Mylist.txt
(bombs out like crazy - LOL)
Thanks for that explanation Mac ...... I'm sure I'll be using it in the future
Actually, I need the size. I first do a search of all files by K size>> 1my.txt then sort that by a byte size and exclude certain directories >> 2my.txt It's from 2my.txt that I need to search the remaining files by string.
TIA
Quote TIA
TIA? Is there an outstanding question? LOL. I thought I was finished here. Maybe I misunderstood your previous post...........
QuoteUh, yep, the tokens stuff should work if you can't avoid the date.
Were you suggesting that tokens will work in 9X?Sorry, my friends tell me 98 does not support date /t so I don't know how you get the date there.
Bummer
Mac Think we got crossed somewhere on what I'm trying to achieve.
I have a text file of filenames with path, and the file size. File size precedes the path/name.
I need to search every file in that text for a string and output the results to another text.
No date involved, and it's my understanding that 9X does not support tokens option, therefore the use of ' for /f %%i in (my.text) do find "string" %%i >> my2.txt' will try to search the string from the filesize rather than the path/filename. Will putting the filesize after the path in my.txt allow it to search the files?
example of current my.txt
19225 C:\windows\filen.ame 19225 C:\progra~1\Norton\filen.ame
if changed to,
C:\windows\filen.ame 19225 C:\progra~1\Norton\filen.ame 19225
will %%i search the files for string as if the size isn't even present?
QuoteT will %%i search the files for string as if the size isn't even present?
I'm pretty sure. The variable, %%i, will be set to the first string up to a space, the default delimiter.
At least I know the following works on NT4:
Code: [Select]echo C:\windows\filen.ame 19225 > z.txt echo C:\progra~1\Norton\filen.ame 19225 >>z.txt for /F %%i in ('type z.txt') do ( echo Got a filename echo It's name is %%i echo So I am happy )
Mac
Thanks. I'll give it a try on 9X.
|