I can rename the files in all the directories and sub directories using the following script
@Echo OFF
FOR /D /R %%# in (*) DO (
PUSHD "%%#"
FOR %%@ in ("index*") DO (
Echo Ren: ".\%%~n#\%%@" "%%~n#%%~x@"
Ren "%%@" "%%~n#%%~x@"
)
POPD
)
Pause&ExiT
is there a way to modify the script, which worked fine for me in the 2nd answer to rename files in a sequence when there is multiple files in the directory?
Like, the folder name is image
and I want the files to be named image1.jpg
image2.jpg
(retaining the extension).. Help is much appreciated
Try this:
@Echo OFF
setlocal enabledelayedexpansion
FOR /D /R %%# in (*) DO (
PUSHD "%%#"
FOR %%@ in ("index*") DO (
set /a "inc+=1"
Echo Ren: ".\%%~n#\%%@" "%%~n#!inc!%%~x@"
Ren "%%@" "%%~n#!inc!%%~x@"
)
POPD
)
Pause&Exit
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.