I have a DCIM directory containing photos named as IMG_{NNNN}.JPG from iPhone and photos named as DSC_{NNNN}.JPG from Xperia. This directory is the result of multiple directories merging, which all had different photos with same names (eg iPhone 3GS' .../DCIM/IMG_0001.JPG, iPhone 4S' .../DCIM/IMG_0001.JPG and iPhone 5s' .../IMG_0001.JPG different photos or Xperia Z3+'s before restore .../DCIM/100ANDRO/DSC_0001.JPG and Xperia Z3+'s after restore .../DCIM/100ANDRO/DSC_0001.JPG different photos). To rename photos so none went overwritten by another, I searched 'holes' in the list (eg if PIC10.JPG has been deleted since but PIC9.JPG and PIC11.JPG are still here, I have a hole so I can rename the second PIC1.JPG to PIC10.JPG so I don't lose it and don't end up with a messy directory containing files looking like doubles by the name).

I want to keep the current nomenclature for photos such as iPhone photos in IMG_{NNNN}.JPG and Xperia photos in DSC_{NNNN}.JPG.

I want to rename the photos in the order they were taken from the EXIF data (eg if the above example's PIC1-2.JPG that went PIC10.JPG has been shot before PIC1.JPG then this PIC10.JPG becomes PIC1.JPG and all subsequent photos are renamed as PIC{N+1}.JPG, or PIC{N+X}.JPG if x photos come at the list's beginning) — putting exifless photos first (ie the first exifless photo found becomes PIC1.JPG, the second becomes PIC2.JPG etc).

I do not want to rename the photos otherly than with their initial nomenclature (ie no { Date } iPhone photo.jpg or Xperia photo from { Date }.jpeg).

Is there any way to do this simply? I'd rather get a command line way to do this, but even an Automator script or combined approach (eg an Automator script calling a shell script) will do just fine — as long as once the thing starts running, I don't have to touch the keyboard until the job's done.

Thank you.

  • You can use Python. Try this script. – Michael D Jun 27 '16 at 11:31
  • Welcome to Super User! Please note that Super User is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read How do I ask a good question?. – DavidPostill Jun 27 '16 at 22:32
  • @MichaelD Unfortunately, the script renames as date[8:10] + '-' + date[5:7] + '-' + date[:4] + image_format. I think it needs conditions to only increase the four digits number by one from the older to the newer, but I'm not sure about how to write that. Thanks though. – user2189 Jun 27 '16 at 22:35
  • @DavidPostill Hello. I haven't tried any script [except Michael D.'s link's] so far as I could not find a script that does what I want it to do. I guess you imply that this post belongs to Stack Overflow, sorry for the wrong place. – user2189 Jun 27 '16 at 22:37
  • @kvpb Wherever you post we expect some effort. It would also get closed on Stack Overflow for lack of effort. – DavidPostill Jun 27 '16 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.