Trying to switch to Exiftool from jhead to rename more filetypes other than jpg & jpeg.

Whats the script for exiftool to convert from jhead:

jhead -n"%Y_%m_%d-newname-%04i" *.jpg

output: 2019_10_05-newname-0001.jpg

*.jpg as multiple files


1 Answer 1


Jhead's -n option appears to read the DateTimeOriginal tag for the timestamp so you would be doing a tag copy from DateTimeOriginal to Filename. You would use the -d (dateFormat) option to format the timestamp to your pattern and exiftool uses about the same format as JHead (see here for exiftool date formatting variables).

Exiftool has the FileSequence tag that will holds the file count. In order to pad that out to four places, you have to use the Advanced formatting feature and a bit of perl code.

The end result would be something like this:
Windows: exiftool -d "%Y_%m_%d" "-Filename<${DateTimeOriginal}-newname-${FileSequence;$_=sprintf('%04d', $_ )}.%e" <FilesOrDirs>

Mac/Linux: exiftool -d '%Y_%m_%d' '-Filename<${DateTimeOriginal}-newname-${FileSequence;$_=sprintf("%04d", $_ )}.%e' <FilesOrDirs>

Replace Filename with Testname to test the command without actually renaming any files. Swap single/double quotes if running Mac/Linux to avoid bash interpreting parts of the command as variables. Add -r (recurse) option to recurse into subdirectories.

  • \$\begingroup\$ Thankyou, I tried your script and used the Testname on a jpg file, output gave: “Warning: syntax error for ‘FileSequence’ - /Dir/.../.../image.jpg” - “/Users/name/Desktop/Folder’ —> ‘2010_04_25-Newname-12.jpg” \$\endgroup\$
    – jcron13
    Nov 6, 2019 at 4:15
  • \$\begingroup\$ Using MacOS, I also changed the quotes from double to single. \$\endgroup\$
    – jcron13
    Nov 6, 2019 at 4:29
  • \$\begingroup\$ Swap all quotes. Change all single quotes to double and all double quotes to single. Make sure you're not using Fancy Quotes ❝ ❞ ❛ ❜ because some macs are set up to automatically "help" by changing regular quotes into fancy quotes. \$\endgroup\$
    – StarGeek
    Nov 6, 2019 at 18:31
  • \$\begingroup\$ Thanks It worked, I edited your original comment to include MacOS. \$\endgroup\$
    – jcron13
    Nov 6, 2019 at 21:57
  • \$\begingroup\$ Now Im renaming a MP4 file, it gave an error output: Warning: [minor] The ExtractEmbedded option may find more tags in the movie data - /User/name/Pictures/Videos/Vid001.MP4 Warning: No writable tags set from /User/name/Pictures/Videos/Vid001.MP4 \$\endgroup\$
    – jcron13
    Nov 6, 2019 at 22:20

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.