1.

Solve : batch file to list log files?

Answer»

hello,

I would like to make a batch file that will list all the log files and their location on my MACHINE into a TEXT file. I don't QUITE know how to do it. dir was the closest thing to a list command I COULD think of.

here is what I've been trying

Code: [Select]@FOR /R %%G IN (*.log) DO dir /s "%%G" > "C:\Documents and Settings\chin\Desktop\file.txt"

this isn't doing quite what I want, am I barking up the wrong tree with what I have here so far?

thanks for your time.


Don't necessarily need to do this in a batch file, unless you really want. But can be done with the dir command.

For example:

dir *.log /s > file.txt

When doing the above command it will list each of the log files and will also list the directory of. Unless you're wanting it formatted in a certain way I think this will do everything you want.

Thanks, that works. Why didn't the code I was trying work? They seem similar.Quote from: chin on February 28, 2008, 05:10:18 PM

Thanks, that works. Why didn't the code I was trying work? They seem similar.
It MAY have been your /s in the DIR command, or maybe the redirection being "create" instead of "append"
Maybe you could have tried
@FOR /R %%G IN (*.log) DO dir "%%G" >> "C:\Documents and Settings\chin\Desktop\file.txt"You're right, GuruGary. It works now.

Thanks



Discussion

No Comment Found