How do I use jhead to rename photos by date with a sequential counter?
Asked 9/17/2019
6 views
2 answers
0
I want to rename JPEGs with jhead on macOS so the filename includes the photo date plus a custom name and a zero-padded sequence number, for example: YYYY_MM_DD-newname-001.jpg, YYYY_MM_DD-newname-002.jpg. How should I format the -n pattern, and should I use %f if I want the files numbered sequentially?
Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0
Photography Stack Exchange contributor
6y ago
2 Answers
1
I'm not quite sure what you're after, but:
$ ls *.jpg
foo.jpg
$ jhead -n"%Y%m%d%H%M-%f-renamed" foo.jpg
foo.jpg --> 201909141339-foo-renamed.jpg
$ ls *.jpg
201909141339-foo-renamed.jpg
The usage documentation for jhead is quite good, and you might want to check the manual for strftime (if you're on a Unixoid system, which it looks like you are), which is where all of the time-and-date formatting stuff comes from. But note that jhead has some additional options, such as %f that I used above.
Originally by user82065. Source · Licensed CC BY-SA 4.0
user82065
6y ago
0
Generated from our catalog & community — verify before relying on it.
Use jhead’s -n pattern with date codes plus %03i for a 3-digit running counter. For example:
jhead -n"%Y_%m_%d-newname-%03i" *.jpg
That will produce names like:
2019_09_14-newname-001.jpg2019_09_14-newname-002.jpg
If you include %f, jhead inserts the original filename, so you won’t get a clean sequential naming scheme like 001, 002 by itself. %f is useful only if you want to preserve part of the old filename.
The date/time formatting comes from standard strftime codes such as %Y, %m, %d, %H, %M, while jhead also adds options like %f and %i.
So for your goal, omit %f and use %03i for the counter.
Recommended products
UniqueBot
AI6y ago
Your Answer
Related Questions
Can Lightroom export files with zero-padded sequence numbers?
How can I set EXIF date/time from filenames like 2023_01_11_001.jpeg?
How can I rename photo files using the EXIF capture date?
How can I bulk rename photos using EXIF date/time while keeping the original filename?
How can I batch set JPEG photo dates from the date in the filename before uploading to Google Photos?