While copying photos taken during my recent three week trip from several SD cards to my computer drive, I almost lost numerous images because of duplicate filenames. While I was aware that a roll-over from IMG_9999.JPG to IMG_0001.JPG had taken place at some point (so that I had to remember to look for and copy from a DCIM/101CANON as well as the standard DCIM/100CANON directory on one of the SD cards), it was also clear that I had taken waaay less than 10000 pictures (though the actual count of 3700 is already quite substantial). Therefore it took me by surprise (and I would almost not have noticed it before formatting the SD cards) that numerous filenames (such as IMG_3830.JPG through IMG_4242.JPG) were used twice (and thus overwritten by my initial naive copying command).

According to my investigation, the last image on one SD card was IMG_5123.JPG of 5/11/2016 17:49, and then on the next morning, the first image on the next SD card was IMG_9590.JPG of 6/11/2016 09:38!

So, to avoid similar surprises in the future, my questions are:

  • What might have happened and cause the camera to continue with 9590 after 5123? (Any "reset" leading to a restart with 0001 would have been easier to understand)
  • Is there any way to ensure image filenames are "more unique"? (Of course even the possibility to have a fifth digit merely postpones the problem, in particular if "random" jumps as in the first bullet point are still possible)

3 Answers 3


It depends on your camera and model, and what software is in there.

What I have seen with multiple camera models, and that is probably what happened for you too, is that they use the following algorithm:

  • The camera counts internally from 0001 to 9999, and names the pictures accordingly. After 9999, it simply goes back to 0001; it puts it in a separate directory, but when you copy them together, there is no more difference between the first set 0001 and the second set 0001.
  • if you use a memory card that already has pictures on it, the counter jumps to the last written picture (highest number), and continues after that. So if your camera is at 2000, and you insert a card with a picture numbered 5668, the next shot will become 5669, not 2001 (even if 2001 would be free).
  • if you use multiple cards and each one has already collected some pictures, you can quickly get a complete mess...

There are multiple ways to handle that, and each one has its advantages and disadvantages. Here is my approach: I use only one card per camera, and whenever I download the pictures, I leave the last (highest number) on it, so thecamera continues counting there. On my harddisk, I add additional digits to the four digits that the camera provides, so my pictures are named '6D-0010001'; I use a small renaming tool to rename all files immediately accordingly. As I said, there are many ways, and most people will not like my approach. I recommend you make a plan for yourself how to organize it - unfortunately, you need a plan.

  • \$\begingroup\$ I think this addresses best what happened: I now recall that at one point the card inserted still had old pictures on it, which I deleted accordingly (knowing for sure that I had backed them up at home). So I assume my main lesson learned is to make sure all cards I take with me for a long journey have been formatted before I start. \$\endgroup\$ Commented Nov 16, 2016 at 12:38

When I import images from my Canon cameras using EOS Utility I have it automatically change the filenames to include the date the photo was taken as well as the 4-digit image number assigned by the camera. I also automatically create a folder for each date that images on the card were shot and images are placed in each folder based on the date they were shot.

Operating systems and storage capacities are a lot different than they were 15 years ago when the naming conventions and file structures for the DCIM folder under the Design rules for Camera File Systems were being ironed out. I've never experienced a problem with files named something like 201611150001.cr2. After editing and exporting them they're even longer: 201611150001LR.jpg (low resolution version), 201611150001HR.jpg (high resolution version), 201611150001HRhdrmc.jpg (High resolution HDR monochrome version), etc.

Once images are transferred to the computer and backed up at least two other places the cards are formatted in camera before being used again. I've got the cameras set so the image numbers continue where they left off, even after reformatting the cards. So if the last image of a previous shoot was IMG_6875 I can put any of my various cards in the camera, format the card, and the next image I take will be named IMG_6876.

One thing that may cause the image numbers to be assigned out of sequence is if you swap cards and then put a card you used earlier back in the camera without reformatting it. Putting a card with images taken using one EOS camera stored on it into another EOS camera and recording images to it can also cause gaps in the image numbers.

A word about memory card best practices.

I've shot over a quarter-million frames since going digital in 2008. I have yet to lose a single image due to a corrupt card issue. I have accidentally deleted a few and recovered them with varying degrees of success. I attribute this to several practices that I follow.

  • Reformat the card!

Every camera maker recommends using the camera to reformat the memory card periodically. Doing so helps reduce the risk of data loss because each time a card is reformatted bad sectors can be mapped out of the card's directory. Most memory cards contain more memory than they show. The reserve capacity is used to replace bad sectors when they are detected by the card's on-board memory controller. Deleting some but not all data on a card and then shooting more images increases the risk of corruption with flash memory cards. It can also impact the speed at which your camera can write to the card if the file has to be fragmented over several sectors because it is larger than the space cleared by the image you erased. The increased risk is very slight, but it is there.

  • Always turn off the camera and be sure the card access light has stopped blinking before opening the memory card slot cover.
  • Only remove the card from the camera when absolutely necessary (i.e. the card is full and I'm still shooting a session). This includes transferring images to the computer using the camera, rather than a card reader. I understand not everyone agrees with this preference, but I'd rather wear my batteries out a little sooner than risk losing images due to card insertion errors. Voltage is just voltage, but no two images are the same. If you do use a card reader, be sure to use the OS "eject" command before removing a hot swappable card. For CF cards best practice is to power down the computer before removing the card from the reader. Although the USB reader may be hot swappable, the CF card standard does not include such a requirement.
  • If your camera uses CF cards, be very careful to make sure the pins in the card slot are lined up properly with the holes on your card.
  • Replace your card(s) periodically. Wear leveling helps extend the life of flash memory cards, but they do wear out eventually. If a card starts acting flaky at all, it's time to replace it NOW.
  • \$\begingroup\$ An additional item for your best practice list that I use: Always switch the card to "read only" before inserting it into a card reader. Some OSes tend to create foolish folders on inserted cards, and this also helps if one should forget to "eject". \$\endgroup\$ Commented Nov 16, 2016 at 12:47
  • \$\begingroup\$ I use SD cards even less often than the rare occasion when I use a card reader for a CF card. CF cards don't have a "read only" switch. \$\endgroup\$
    – Michael C
    Commented Nov 16, 2016 at 12:58
  • 1
    \$\begingroup\$ I agree that this is the recommended list, and I know that many world re-known professionals do all this; however, i think it is overshooting the target quite a bit. I have taken about 60000 shots in the last four years, never reformatted a card, and never had any issues. Most problems come from dust/dirt (cards lying loose in some bag); wrong-side forced insertion; not turning the camera off; or - the absolute #1 - taking them out of Windows PCs before they are 'ejected' properly (which works very poorly in all Windows versions, and sometimes I do a reboot just for that). \$\endgroup\$
    – Aganju
    Commented Nov 16, 2016 at 13:09
  • \$\begingroup\$ If you erase all of the images on the card periodically that is almost the same as reformatting from a fragmentation point of view, but not from a bad sector point of view. Agreed that the #1 problem is removing a card when it is being written to by the device. Why do you refuse to format your cards, though? \$\endgroup\$
    – Michael C
    Commented Nov 16, 2016 at 13:31
  • \$\begingroup\$ Definitely agree on the renaming convention, although in todays world of burst shooting in excess of 10fps, I've had to modify the convention I use to YYYYMMDDhhmmss-nnnn.jpg, where nnnn is the original shot number from the original IMG_nnnn.jpg name. Although it could really just be any arbitrary number to avoid name collisions... \$\endgroup\$
    – twalberg
    Commented Nov 17, 2017 at 13:51

I don't know if the question is asking about what caused the problem to occur or how to avoid duplicate filenames. For the latter, I keep all my photos in separate directories by date. That way, I'm never going to have a filename conflict unless I take more than 10000 photos in one day (very unlikely). It also makes it much easier to find the photos later on.

When you name the directories, make sure to use the YYYY-MM-DD format, as this will sort the directories in chronological order when you sort by name. You might also want to put a short description of the contents afterwards e.g. 2017-03-25 John's birthday party.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.