Batch Photo Files Rename Tools (by EXIF).

Overview

Requirement

Most cameras' filenames are like 'DC*****' or 'P*****', I want to find a tool that has the following features.

  1. Batch change filenames to P[photo capture date]-[camera model].jpg. For example, P20220710-101405-iPhone 13.jpg.
  2. Can change the camera model string, for example, I want to change "iPhone 6" to "i6", "DMC-G6" to "G6", "DSC-RX100M5A" to "R1005A", ...
  3. Can add a serial number automatically when the new filename is duplicated with others.

Software

There are lots of rename tools. I try 3 tools, and all of them are freeware. (Rename Master is not open source, but it's not a problem.). F2 (by Go and ExifTool (by Perl) are cross-platform. Rename Master is for Windows only.

F2

  1. First run, use its build-in function, the problem is it cannot get the capture date.

    1C:\>f2 -r 'P{{mtime.YYYY}}{{mtime.MM}}{{mtime.DD}}-{{mtime.H}}{{mtime.mm}}{{mtime.ss}}-{{x.model}}'
    2β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    3| ORIGINAL     | RENAMED                 | STATUS |
    4| *********************************************** |
    5| P1790419.JPG | P20220528-154122-DMC-G6 | ok     |
    6| P1790420.JPG | P20220528-154134-DMC-G6 | ok     |
    7| P1790421.JPG | P20220528-154140-DMC-G6 | ok     |
    8β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    9INFO  Use the -x or --exec flag to apply the above changes
    
  2. Second run, use ExitTool to get the capture date. Because the date format of DateTimeOriginal is something like 2003:10:31 15:44:19, it contains several commons and it's an invalid character in Windows file system.

    1C:\>f2 -r 'P{{xt.DateTimeOriginal}}-{{x.model}}'
    2β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    3| ORIGINAL     | RENAMED                       | STATUS                                |
    4| ************************************************************************************ |
    5| P1790419.JPG | 'P2022:06:25 10:47:16-DMC-G6' | invalid characters present: (:,:,:,:) |
    6| P1790419.JPG | 'P2022:06:25 10:47:21-DMC-G6' | invalid characters present: (:,:,:,:) |
    7| P1790419.JPG | 'P2022:06:25 10:47:27-DMC-G6' | invalid characters present: (:,:,:,:) |
    8β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    9ERROR  Resolve conflicts before proceeding or use the -F flag to auto fix all conflicts
    
  3. Third run, in ExifTool, you can change the format of DateTimeOriginal, it seems we cannot do it in F2. Therefore, please add a -F parameter, it will try to fix invalid characters. In this case, it removes all invalid characters.

    1C:\>f2 -r 'P{{xt.DateTimeOriginal}}-{{x.model}}' -F
    2β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    3| ORIGINAL     | RENAMED                   | STATUS |
    4| ************************************************* |
    5| P1790419.JPG | 'P20220528 154122-DMC-G6' | ok     |
    6| P1790420.JPG | 'P20220528 154135-DMC-G6' | ok     |
    7| P1790421.JPG | 'P20220528 154140-DMC-G6' | ok     |
    8β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    9INFO  Use the -x or --exec flag to apply the above changes
    
  4. I stop my test here... Because although F2 is very fast, but F2+ExifTool is much slower than F2 only, I guess it's due to F2 calls ExifTool externally. I try to create a feature request to add the support for DateTimeOriginal, I hope the project owner will accept it: https://github.com/ayoisaiah/f2/issues/23

ExifTool

  1. First run, use Exif tool to rename files, because the Exif function is build-in, the peformance is faster than F2+ExifTool.
    1C:\>exiftool "-filename<${CreateDate}-${Exif:Model}.${filetype}" -d P%Y%m%d-%H%M%S%%-c *
    2
    3C:\>dir
    42022/05/28  δΈ‹εˆ 03:41         8,024,576 P20220528-154122-DMC-G6.JPEG
    52022/05/28  δΈ‹εˆ 03:41         6,673,920 P20220528-154135-DMC-G6.JPEG
    62022/05/28  δΈ‹εˆ 03:41         7,978,496 P20220528-154140-DMC-G6.JPEG
    
  2. I cannot find a parameter to show the result, I need to run dir to check the new filenames. If you know how to do it, please let me know, thanks.
  3. I cannot find a function to modify the camera model string in ExifTool, but it's possible to do it by F2 easily. But for my requirement, I need to run F2 many times like the following. It should be ok but I prefer to find a better solution.
    1. Run ExifTool to rename files
    2. Run F2 to rename files for my 1st camera/phone.
    3. Run F2 to rename files for my 2nd camera/phone.
    4. Run F2 to rename files for my 3rd camera/phone.
    5. ...

Rename Master

  1. Finally, I try to use Rename Master, it's a Windows GUI application, you can add actions (add string, find and replace, add serial number, ...). This is my script, it has 5 steps:

    1. Remove all filename.
    2. Add filename with a 'P' character and date+time.
    3. Add camera model into the filename.
    4. Change the name of camera model (ex: "DSC-RX100M2" -> "S2", "iPhone 6 Plus" to "i6")
    5. If the filenames are duplicated, add serian number in last.
  2. If you have hundreds of files, it will hang for several seconds (depending on your files) to scan the file, please be patient!

  3. The following is my script, if you like, you can download it into a xxx.rmscr and use Rename Master to open it. Then you can modify the script for your requirement.

      1[SCRIPT0]
      2TYPE_unicode=7
      3ENABLED_unicode=1
      4cbAndStore_unicode=0
      5cbRCReplace_unicode=0
      6cbxRemoveCharactersPart_unicode=0
      7cbxRemoveCharPosition_unicode=0
      8txtR2X_unicode=50
      9txtRCReplace_unicode=
     10
     11[SCRIPT1]
     12TYPE_unicode=0
     13ENABLED_unicode=1
     14cbOnCollision_unicode=0
     15cbxAddAtThe_unicode=0
     16cbxAddPart_unicode=0
     17txtAdd_unicode=P?x_dtd:FYYYYMMDD?-?x_dtd:FHHMMSS?-
     18
     19[SCRIPT2]
     20TYPE_unicode=0
     21ENABLED_unicode=1
     22cbOnCollision_unicode=0
     23cbxAddAtThe_unicode=1
     24cbxAddPart_unicode=0
     25txtAdd_unicode=?x_mo?
     26
     27[SCRIPT3]
     28TYPE_unicode=3
     29ENABLED_unicode=1
     30cbReplaceOnly_unicode=0
     31cbxReplacePart_unicode=2
     32cbxReplaceTarget_unicode=0
     33txtReplacePhrase_unicode=DSC-RX100M5A
     34txtReplaceWith_unicode=S5A
     35txtRP2X_unicode=1
     36txtRP2Y_unicode=10
     37
     38[SCRIPT7]
     39TYPE_unicode=3
     40ENABLED_unicode=1
     41cbReplaceOnly_unicode=0
     42cbxReplacePart_unicode=2
     43cbxReplaceTarget_unicode=0
     44txtReplacePhrase_unicode=iPhone 6 Plus
     45txtReplaceWith_unicode=i6
     46txtRP2X_unicode=1
     47txtRP2Y_unicode=10
     48
     49[SCRIPT12]
     50TYPE_unicode=0
     51ENABLED_unicode=1
     52cbOnCollision_unicode=1
     53cbxAddAtThe_unicode=1
     54cbxAddPart_unicode=0
     55txtAdd_unicode=-?n02?
     56
     57[Path]
     58cbPath_unicode=
     59
     60[Filter]
     61txtFilter_unicode=*.jpg
     62
     63[ScriptOptions]
     64UseFilter_unicode=1
     65UsePath_unicode=0
     66
     67[Version]
     68Current_unicode=3.9
     69
     70[Counting]
     71rbUsePositionInList_unicode=1
     72rbStartCountingAt_unicode=0
     73txtStartCountingAt_unicode=1
     74txtIncrementBy_unicode=1
     75
     76[Case]
     77cbOverrideCase_unicode=0
     78rbCUppercase_unicode=1
     79rbCLowercase_unicode=0
     80rbCCapitalizeWords_unicode=0
     81rbCCapitalizeSentence_unicode=0
     82cbCPreserverExtension_unicode=0
     83rbCTitleCase_unicode=0
     84cbCRoman_unicode=0
     85cbSplit_unicode=0
     86txtSplit_unicode=
     87
     88[Wildcards]
     89rbWildcards_unicode=1
     90rbRegExp_unicode=0
     91
     92[Text]
     93txtTName_unicode=
     94udTSkip_unicode=0
     95cbTDelim_unicode=1
     96rbTMatch_unicode=1
     97rbTFind_unicode=0
     98txtTFind_unicode=?cfn?
     99txtTDelim_unicode=,
    100cbxSearchWith_unicode=0
    

Conclusion

Other sofotwares

There are lots of rename tools, you can try them...

  • Bulk Rename Utility: it seems this utility has lots of features and it supports writing javascript to rename files. But it's for personal use only, if you want to use it in commercial, you need to pay.
  • Ant Renamer: The last change is 2015/04/07.
  • Ken Rename: I cannot find its official website of it.