Ugly Hedgehog - Photography Forum
Home Active Topics Newest Pictures Search Login Register
Main Photography Discussion
Windows batch file for adding "1" to image numbers once they pass 9999 (ie. 10012)
Page 1 of 3 next> last>>
Jan 7, 2019 11:34:05   #
Longshadow Loc: Audubon, PA, United States
 
For those familiar with Windows Batch Commands, this works for my Canon files.
(Windows (7) shotgun rename apparently cannot insert a character.)

* place images in a individual working directory, like "Renumber".
* place the .cmd file in the same directory.
* in Windows explorer for the "renumber" directory, double click the .cmd file.

It will strip the "IMG_" from the .CR2 and .JPG files and show you what it did (directory listing) and pause.
Then it will add the prefix "IMG_1" to the .JPG and .CR2 files and show you what it did and pause.

You can probably modify it for another camera brand's naming convention. You, or someone, should be familiar with batch commands. You can modify the "1" to "2" when you go past 9999 the second time.
Use a text editor and save the command statements below as RenumberImages.cmd or whatever you want to call it. Yes, I could have put some checks in the file, but I don't need them.

CAVIAT(s):
- Only for those comfortable with batch files!
- Provided without warranty, use at own risk.
- I'm not responsible for any hiccups in what you do.
- Only run it against the files you need to add the "1" to.
- Run only ONCE!
- Test it in a temporary directory with COPIES of the images.
- If you are not sure about batch commands, check with someone who is familiar with them before using.
- Ignore this it if you are not sure....


REM Batch file to add 10,000 to image number once images pass 9999 (ie. 0012).
REM Place this file in a directory where the images are to be renamed, NOT your normal storage directory.
REM or place images in the directory where this file is located.
REM Changes Canon IMG_#### files to IMG_1#### (.CR2 and .JPG).
REM ONLY run it against new files from camera, ONCE.
REM After running, move the renamed files to where you want them.

REM Remove four character prefix to image number.
RENAME "IMG_*.*" "////*.*"
DIR
PAUSE

REM Add prefix back with a 1 for 10K to image number.
FOR %%a in (*.CR2) DO RENAME "%%a" "IMG_1%%a"
FOR %%a in (*.JPG) DO RENAME "%%a" "IMG_1%%a"
DIR
REM DONE
PAUSE

Reply
Jan 7, 2019 11:56:37   #
CHG_CANON Loc: the Windy City
 
Without being too snarky, this is a solution for what problem?

Reply
Jan 7, 2019 11:57:16   #
Longshadow Loc: Audubon, PA, United States
 
Okay, slight hiccup.
Two files get IMG_1 inserted twice.
It worked great last night...

Reply
 
 
Jan 7, 2019 11:58:33   #
Longshadow Loc: Audubon, PA, United States
 
CHG_CANON wrote:
Without being too snarky, this is a solution for what problem?


Image numbering when the camera rolls over to 0000 so there are no duplicates.

Reply
Jan 7, 2019 12:04:10   #
CHG_CANON Loc: the Windy City
 
Longshadow wrote:
Image numbering when the camera rolls over to 0000 so there are no duplicates.

But, there's not any duplicates if you store your images in separate folders, probably a universal best practice. The camera "knows" to put the images in separate folders on the card so it doesn't get confused either.

You can also use, at the minimum, the software that came with your camera to rename images as they are copied from the card, even if you managed to capture 10,000+ onto a single card in a single day.

Personally, I have experienced formatted cards giving me IMG0001 on the same date on different cards where I later wanted to merge into a single folder. I went back to the best practice: each unique card to each unique folder. Once inside the image editor, no issue with overlapping IMG001 file names as they're in unique folders. The Canon utilities, if used, will suffix the images to force uniqueness. But, sorting by file name rather than capture time caused intermingling that is easier to avoid with unique folder names.

Reply
Jan 7, 2019 12:09:14   #
Longshadow Loc: Audubon, PA, United States
 
This bug is going to be fun... At least it's only two.
May take a while.

Before rename
Before rename...

After IMG_ stripped
After IMG_ stripped...

After rename
After rename...

After done (the two renamed manually)
After done (the two renamed manually)...

Reply
Jan 7, 2019 12:58:33   #
Longshadow Loc: Audubon, PA, United States
 
CHG_CANON wrote:
But, there's not any duplicates if you store your images in separate folders, probably a universal best practice. The camera "knows" to put the images in separate folders on the card so it doesn't get confused either.

You can also use, at the minimum, the software that came with your camera to rename images as they are copied from the card, even if you managed to capture 10,000+ onto a single card in a single day.

Personally, I have experienced formatted cards giving me IMG0001 on the same date on different cards where I later wanted to merge into a single folder. I went back to the best practice: each unique card to each unique folder. Once inside the image editor, no issue with overlapping IMG001 file names as they're in unique folders. The Canon utilities, if used, will suffix the images to force uniqueness. But, sorting by file name rather than capture time caused intermingling that is easier to avoid with unique folder names.
But, there's not any duplicates if you store your ... (show quote)

I use Windows Explorer to copy files from the cards to the hard drives on two systems.
I sort by subject. If many pics, sub-directories by date.
If only a few, same directory.
I don't want two different images with the same filename on my system.
But that's just me.

Reply
 
 
Jan 7, 2019 13:01:58   #
CHG_CANON Loc: the Windy City
 
You might look into Perl if you want to program a robust solution to this rather unique problem (ref: same filename on my system) ... Or the software that came from the camera, see if time (or subject or date or other) can be added to the file name while loading from the card. Best practices tend to get that name for a reason.

Reply
Jan 7, 2019 13:32:09   #
Steve DeMott Loc: St. Louis, Missouri (Oakville area)
 
With LR & PS bundle from Adobe, you also have Adobe Bridge. It has an excellent renaming tool.
Relying on MY type skills is not something I would rely on with DOS Commands

Reply
Jan 7, 2019 14:28:26   #
DirtFarmer Loc: Escaped from the NYC area, back to MA
 
So it appears to me that this requires that you download your new files to a temporary folder, then run the batch file, then move the new files to your photo folder.

Why not just use a new subfolder of your photo folder? No renaming needed. Just download the new files there.

Or even better, give the files a meaningful name. What is IMG_5482 a photo of? You certainly can't tell from the file name. You could put the new files in a folder with a meaningful name (might be easier to generate one folder with a given name than to change all the file names). But if you copy a file to somewhere else it's really useful to have a meaningful name on that file so that 3 years from now you don't have to go opening all your image files to figure out what it's a photo of.

If you give the files a meaningful name include the date in the new name so if you're dealing with recurrent events (e.g. Suzie's Birthday Party) you won't get new duplicate file names in the future. I used to use an index number to differentiate between different shots in the same group but when I started using more than one camera body it became difficult to organize the files from different cards so that they were sorted chronologically. So instead of an index number I now use the time as well as the date.

Reply
Jan 7, 2019 14:33:18   #
Dngallagher Loc: Wilmington De.
 
Longshadow wrote:
I use Windows Explorer to copy files from the cards to the hard drives on two systems.
I sort by subject. If many pics, sub-directories by date.
If only a few, same directory.
I don't want two different images with the same filename on my system.
But that's just me.


Exactly why I rename all images on import into Lightroom. In my opinion, a naming system that rolls over at 9999 and starts again is really worthless. For me, renaming files with my initials plus the date and time taken assure me of never having a duplicate file, has worked out in over 60,000 files so far, and is transparent as it occurs on import from my SD card.

Reply
 
 
Jan 7, 2019 14:38:01   #
Longshadow Loc: Audubon, PA, United States
 
Got it I think... The wild card for the file name does something funny, like it was adding 1 to the count.
Since there are only four digits remaining in the stripped file name, changing the set name from (*.CR2) to (????.CR2) appears to work. (It will also prevent any .CR2 or .JPG files that were not stripped down to four digits from being modified if they exist.)

Updated script:

REM Batch file to add 10,000 to image number once images pass 9999 (ie. 0012).
REM Place this file in a directory where the images are to be renamed, NOT your normal storage directory.
REM or place images in the directory where this file is located.
REM Changes Canon IMG_#### files to IMG_1#### (.CR2 and .JPG).
REM ONLY run it against new files from camera, ONCE.
REM After running, move the renamed files to where you want them.

REM Remove four character prefix to image number.
RENAME "IMG_*.*" "////*.*"
DIR
PAUSE

REM Add prefix back with a 1 for 10K to image number.
FOR %%a in (????.CR2) DO RENAME "%%a" "IMG_1%%a"
FOR %%a in (????.JPG) DO RENAME "%%a" "IMG_1%%a"
DIR
REM DONE
PAUSE

Reply
Jan 7, 2019 14:39:17   #
Longshadow Loc: Audubon, PA, United States
 
Dngallagher wrote:
Exactly why I rename all images on import into Lightroom. In my opinion, a naming system that rolls over at 9999 and starts again is really worthless. For me, renaming files with my initials plus the date and time taken assure me of never having a duplicate file, has worked out in over 60,000 files so far, and is transparent as it occurs on import from my SD card.


That may help, if I used Light Room.

Reply
Jan 7, 2019 14:42:04   #
CHG_CANON Loc: the Windy City
 
My LR catalog says I have 76,517 images this afternoon. Just grabbing one randomly, I see I have three unique images with counter 9212. That seemed low / not what I wanted to demonstrate. Using 8212 gave me 10 files, none of them the same nor related. But, they're all in unique folders if I had a need to worry about the filename. I don't. They're in collections and have keywords as well as all their uniquely identifying meta data. When I want to manage the file name, I adjust it on the export. This detachment from the OS / folder / filename isn't unique to LR.

Reply
Jan 7, 2019 14:56:21   #
Longshadow Loc: Audubon, PA, United States
 
DirtFarmer wrote:
So it appears to me that this requires that you download your new files to a temporary folder, then run the batch file, then move the new files to your photo folder.

Why not just use a new subfolder of your photo folder? No renaming needed. Just download the new files there.

Or even better, give the files a meaningful name. What is IMG_5482 a photo of? You certainly can't tell from the file name. You could put the new files in a folder with a meaningful name (might be easier to generate one folder with a given name than to change all the file names). But if you copy a file to somewhere else it's really useful to have a meaningful name on that file so that 3 years from now you don't have to go opening all your image files to figure out what it's a photo of.

If you give the files a meaningful name include the date in the new name so if you're dealing with recurrent events (e.g. Suzie's Birthday Party) you won't get new duplicate file names in the future. I used to use an index number to differentiate between different shots in the same group but when I started using more than one camera body it became difficult to organize the files from different cards so that they were sorted chronologically. So instead of an index number I now use the time as well as the date.
So it appears to me that this requires that you do... (show quote)


Contextually renaming may be on an as needed basis as I store images in a subject directory. I can view all of "SuziesBirthdayParty" in the directory, no need for me to rename each file. I can sort on date created for chronology, or camera used. I have those fields showing in Windows Explorer (as well as aperture, speed, focal length, and a bunch of other fields), and using split view, it shows the JPEG on the right. I've been programming and using computers for over 45 years, I don't like duplicate file names with different contents.
Hope that explains some of my philosophy.

Reply
Page 1 of 3 next> last>>
If you want to reply, then register here. Registration is free and your account is created instantly, so you can post right away.
Main Photography Discussion
UglyHedgehog.com - Forum
Copyright 2011-2024 Ugly Hedgehog, Inc.