Hi guys I'm new to batch and have a question for my .bat to rename files.
I looked at the following solution and tried to transfer this to my problem: Renaming file names with a BAT file
So my .bat looks like this one:
setlocal enabledelayedexpansion
set /a count=1
set padded_count=000!count!
for /f "tokens=*" %%a in ('dir /b /od *.txt') do (
ren "%%a" !padded_count!.txt
set /a count+=1
)
And I have a file with random names for .txt data. E.g.
abc.txt
def.txt
123.txt
456.txt
And I want to change these into:
0001.txt
0002.txt
...
But when I use my .bat its just the first .txt which changes its name. Can you explain me why? And what should I do to get all of these.
Or is it possible to handle this problem with REN in cmd with something like "ren *.txt ___"