Batch Scripting

techi3

In Runtime
Messages
119
I wrote this to search my folder for all .doc files but it is not working, please help

@echo off
for %%c (c:\john\\*.doc) do echo %%c

I'm not typing it directly into the CL, I know that it doesn't like double %'s for variables
 
You left out the word "in" in the For command and you have an extra \ in there. Try:

@echo off
for %%c in (c:\john\*.doc) do echo %%c
 
This is where *nix shell scripting is just, well, better!

find /usr/john -name *.doc

:)
 
Seems about the same to me, not necessarily better or easier, just different.

The OP could actually just use the DIR command to accomplish the same thing:

@Echo off
dir c:\john\*.doc /B
 
Last edited:
Seems about the same to me, not necessarily better or easier, just different.
I was referring to the lack of a loop, but as you pointed out the dir command can do it pretty similarly.
 
Thanks for all the help. I finished UNIX shell scripting last week, I just started Windows batch scripting. Tonight's homework is to create a batch backup script to make a copy of each file and rename it with a different format. Then use commands to schedule the script to run daily...fun stuff.
 
Back
Top Bottom