I'm using pyrenamer
with my photo collection and it works great except for one issue. I want it to rename photos by their date taken metadata, with a three-digit number at the end. Each folder in my library represents a day, and I want the photos ending in numbers from 001-999, starting with 001 for each folder. An example file name would be 2016-01-31-001.jpg.
Shotwell handles creating the directory structure on import with a %Y/%m/%d
structure in the options, but when I use pyrenamer recursively in the ~/Pictures directory, I don't see the expected outcome. It renames by date but continues incrementing up across folders, instead of starting at 001 for each new folder. Is there an easier way to go about this?
I know I could add more metadata variables and rename according to hours, minutes, and seconds, but this gives longer file names than I want. My camera also can take multiple shots per second so this is problematic for renaming.
What's the easiest way to do this please? I like using pyrenamer but a bash script is fine also.
Current output:
Pictures/
├── Folder 1/
│ ├── YY-MM-DD-001.jpg
│ └── YY-MM-DD-002.jpg
├── Folder 2/
│ ├── YY-MM-DD-003.jpg
│ └── YY-MM-DD-004.jpg
...
Desired output:
Pictures/
├── Folder 1/
│ ├── YY-MM-DD-001.jpg
│ └── YY-MM-DD-002.jpg
├── Folder 2/
│ ├── YY-MM-DD-001.jpg
│ └── YY-MM-DD-002.jpg
...
To rename your entire image library of JPEG photos to the YYYY-MM-DD-XXX.jpg format, counting up and starting from -001 each new day, use this command with
exiftool
:To explain the command fully, here's how it works.
exiftool
starts the script.-fileOrder DateTimeOriginal
forces exiftool to process the images in the same order they were taken. This is critical to preserve the image numbering within a day in the original chronological order.-recurse
recursively processes subdirectories, which is helpful if you use Shotwell to import because photos are placed in directories organized by date.-extension jpg -extension jpeg
will make sure only JPEG files are processed. (Note these aren't case-specific and jpg=JPG so we catch everything)-ignoreMinorErrors
Ignore any errors which don't affect our desired result (usually problems reading unrelated tags which aren't necessary for this operation).'-FileName<CreateDate'
Puts the photo created date in the file name.-d %Y-%m-%d%%-.3nc.%%e
Here-d
sets the desired output date format. We'll use hyphenated four-digit year then two-digit month and day (%Y-%m-%d
) followed by a three-digit number starting with 001 (%%-.3nc
), preserving the original file extension (.%%e
).~/Pictures/
is the last item, it's just the directory thatexiftool
should process with the command.A note about errors, the
-ignoreMinorErrors
helps but still you may see the message "Warning: Bad PreviewIFD directory" which is safe to ignore or "Warning: No writable tags set from /path/to/problem/image.jpg". The second one I couldn't resolve but I only saw it for a few images, so I manually renamed them in Nautilus as a workaround.This command could still be improved but it is tested and working on a large (40GB, 13000 images) photo library and it's quick and produces no errors, only failing to rename the occasional image that is missing a tag that most any modern camera will create.