I have a folder called sales. I have imgxy.jpg, imgab.jpg etc in that folder. When I right click the sales folder and send to rename.bat file (I have already copied the rename.bat file into c:\documents and settings\username\send To) I want the files in the sales folder to change to sales1.jpg, sales2.jpg etc. This behaviour should be true for anything I send to this .bat file. The following code was working properly on windows 7 last night. Now I am om windows xp sp3 and it doest work. It is trying to rename files in the folder *c:\documents and settings\username*
Please help rename.bat file code below
@ECHO OFF
setlocal enabledelayedexpansion
set foldername=%1
for %%i in (%bar%) do set bar=%%~ni
FOR /D %%# in (%bar%) DO (
PUSHD "%%#"
FOR %%@ in ("*") DO (
set /a "inc+=1"
Echo Ren: ".\%%~n#\%%@" "%%~n#!inc!%%~x@"
Ren "%%@" "%%~n#!inc!%%~x@"
)
POPD
)
Test this - it accepts a folder, not files, but you mentioned folders in your question.
Don't call it
rename.bat
becauserename
is an internal command.