I wrote a simple .bat
file that appends the string "somethingnew"
infront of .txt
files:
for %%x in (*.txt) do ren "%%x" "somethingnew%%~nx.txt"
But when I run it, it renames every file correctly, but at the end it renames the first file again.
For example, if there are 2 files 1.txt
and 2.txt
then this would happen:
1.txt
becomessomethingnew1.txt
2.txt
becomessomethingnew2.txt
somethingnew1.txt
becomessomethingnewsomethingnew1.txt
I found similar questions like this one, but instead, the for loops run twice for every file, while here it runs twice for the first file, so I'm not sure what the solution is.
Thanks.