Rename list of files in Dos script

Closed
Report
Posts
1
Registration date
Wednesday May 19, 2010
Status
Member
Last seen
May 19, 2010
-
 infomik mdr -
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 replies

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
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