Hello everyone,
can any good soul help me with small script please?
I want following thing:
to rename jpgs in one directory from something like photo-1, photo-12, photo-54, photo-112 etc. to photo-1, photo-2, photo-3, photo-4 etc in this exact order
now where i see problem is that it mix order during rename operation (it must not take and rename photo-112 before photo-54 etc. which actully happened when i tried something on my own
Rename batch script
Moderator: DosItHelp
-
- Posts: 100
- Joined: 16 Dec 2016 22:31
Re: Rename batch script
@horus117
I am assuming that all files are in jpg format and filenames are in photo-%var% where %var% is a variable number. If i got your problem right this script would help.
EDIT: this script won't close automatically. You manually need to close it.
I am assuming that all files are in jpg format and filenames are in photo-%var% where %var% is a variable number. If i got your problem right this script would help.
Code: Select all
@echo off
set ren1=1
set ren2=1
:loop
if exist photo-%ren1%.jpg (
ren photo-%ren1%.jpg photo-%ren2%.jpg
set /a ren2+=1
)
set /a ren1+=1
goto loop
EDIT: this script won't close automatically. You manually need to close it.
Re: Rename batch script
Wow, thank you very much sir! Its exactly what i needed.
-
- Posts: 100
- Joined: 16 Dec 2016 22:31
Re: Rename batch script
This script is a bit better. It would close automatically after renaming all your jpg files in current directory.
Code: Select all
@echo off
set ren1=1
set ren2=1
set count1=0
set count2=0
for %%a in (*.jpg) do set /a count1+=1
:loop
if exist photo-%ren1%.jpg (
ren photo-%ren1%.jpg photo-%ren2%.jpg
set /a ren2+=1
set /a count2+=1
if %count1% equ %count2% exit
)
set /a ren1+=1
goto loop