I wish to rename all files inside the folder *.txt, so the result will be "1.txt", "2.txt" and "3.txt", ....
How can I do so?
Select the files you want to rename. Press F2 key. Type a new name for your files and then press Enter.
You can press and hold the Ctrl key and then click each file to rename. Or you can choose the first file, press and hold the Shift key, and then click the last file to select a group.
The following may accomplish what you are looking for. It uses a for
loop to iterate through the text files and makes a "call" to another bit of the batch file to do the rename and increment of a variable.
Edit Change math operation to cleaner solution suggested by Andriy.
@echo off
set i=1
for %%f in (*.txt) do call :renameit "%%f"
goto done
:renameit
ren %1 %i%.txt
set /A i+=1
:done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With