1.

Solve : Commands in bat file?

Answer»

Hi

If i use the following DOS commands individulaly in the DOS window to search for a file and then copy the file the commands work but if i add these two commands to a bat file then they do not work.

DIR /S /B C:\rename\tt1-10.txt> TMP.DIR
FOR /F %F IN (TMP.DIR) DO COPY %F c:\auto\com1\tt1-10.txt /y

Am i missing something.

ThanksQuote

but if i add these two commands to a bat file then they do not work

Does not work how? You are overwriting a single file so that only the data in the last file copied will exist in c:\auto\com1\tt1-10.txt.

The most obvious error is the lack of double % WITHIN the batch file. A potential error EXISTS if the file names have embedded spaces.

Code: [Select]DIR /S /B C:\rename\tt1-10.txt> TMP.DIR
FOR /F "tokens=* delims=" %%F IN (TMP.DIR) DO COPY "%%F" c:\auto\com1\tt1-10.txt /y

Thanks for the help, WORKS now.

Thanks


Discussion

No Comment Found