Rename list of files in Dos script

Closed
munstermum Posts 1 Registration date Wednesday May 19, 2010 Status Member Last seen May 19, 2010 - May 19, 2010 at 11:29 AM
 infomik mdr - Jun 9, 2011 at 05:02 AM
Hello,
I have a list of files that I need to rename
basically what I'm doing is
dir/b *.csv > out.tmp - to get my llist of files

for /f %%a in (out.tmp) do ( ren %%a %timestamp%-%%a)

Problem is if the file name for example was Test one.csv - it only finds the file name as being test - so it cant find the file.
Is there somewhere that I should be placing quotes?
Thanks



2 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
May 19, 2010 at 04:43 PM
Does it has to be DOS. VBS would be far easier and more powerful
1
i think it's because of space in the name of files you can inspire from this

Dir /A-D /B *.pdf > files.txt
for /f "usebackq delims==" %%a in (files.txt) do ( rar a -m5 -p1234 "%%a.rar" "%%a")
pause

i use it to compress files in a folder files.txt contains the name of files to compress each line is a name for one file, so the script proceed line by line

hope that can help you.
0