Hello,
I have many files in one folder. Here is one exemple of file name :
pics - 05/02/2005 001.jpg
...
pics - 05/02/2005 300.jpg
I wish I could reverse the numerotation of the files :
pics - 05/02/2005 001.jpg will become pics - 05/02/2005 300.jpg
...
pics - 05/02/2005 300.jpg will become pics - 05/02/2005 001.jpg
Is it possible ?
I don't really know how to script but I really need to do that!!
Could somebody help me please ?
This demo assumes that all the files match the wildcard pics*.jpg
(where * means any number of characters). It also assumes that
the final numbering characters match a three digit range 001-999.
It should prompt you for the start number (in your example = 1)
and the finish number (in your example=300) and then rename
each file to (Start+Stop)-(file's current number) with lead zeros for
numbers less than 100. So in your example, 001 becomes 300,
300 becomes 001 and so on.
Note that the demo does an intermediate REName to *.JP_
(assumes you have no files with extension .JP_ at present), to
avoid clashing with existing files during the process. At the end
of the run all the *.JP_ files are RENamed back to *.JPG extension.
Try it out on a few copied example files first to see if it does what
you want.
Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
SETLOCAL
SET /p START="Enter start of file numbering "
SET /p STOP="Enter end of file numbering "
SET /a TOGGLE=%START%+%STOP%
:: Assumes files match pics*.jpg
FOR %%F IN (pics*.jpg) DO CALL :_RENAME "%%F"
ECHO. Renaming all *.JP_ to *.JPG
REN *.JP_ *.JPG
GOTO :EOF
:_RENAME
SET BN=%~n1
SET FirstPart=%BN:~0,-3%
SET LastThree=%BN:~-3%
SET /a LastThree=1000+%TOGGLE%-%LastThree%
SET LastThree=%LastThree:~-3%
ECHO. Renaming %1 to "%FirstPart%%LastThree%.JP_"
REN %1 "%FirstPart%%LastThree%.JP_"
====End cut-and-paste (omit this line)
Simulated Win2000 for study/demo use. Cut-and-paste as Batch text file.
Batch file troubleshooting:
http://www.allenware.com/find?UsualSuspects