Batch rename files using REN in Windows 7 (adding prefix)

user2237330 picture user2237330 · Apr 2, 2013 · Viewed 40.8k times · Source

I have figured out how to edit batches of files using REN in Windows 7 Command Prompt. However, this time, I am trying to add a prefix to all files but I am unable to do it. All files are tif files.

For instance, files are located in C:\Users\user1\Desktop\Test_Folder
Files inside each folder begin with 9.
Each file has 5 digits (i.e 90200, 90201, 90202).

I am trying to add a 0 (zero) in front of each file name and change it to 090200, 090201, 090203....

I tried:

FOR %v IN (?????.tif) DO REN %v 0%v

I also tried:

FOR %%a in (*.tif) DO REN "%%a" "0%a"

Please help.

Answer

user1573932 picture user1573932 · Apr 11, 2013

This one is simpler ...

forfiles /M *.tif /C "cmd /c ren @file 0@file"

Source: https://www.windows-commandline.com/rename-file-extensions-bulk/