ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: prep8r8tor on January 28, 2025, 12:43:55 PM

Title: Sort photos by year, copy, rename by datecreate globally number with one command
Post by: prep8r8tor on January 28, 2025, 12:43:55 PM
Hello,
with this command I can copy and rename my photos recursively in a nice and practical way:

exiftool -r -o DummyDir/ '-filename</media/user/nikon-test-global/${DateTimeOriginal}_${ImageSize}_${Model;}%-c.%le' -d '%Y.%m.%d-%H-%M-%S'

But I want to copy all photos according to the 'DateTimeOriginal' 'model' etc., rename them and sort them into year folders. Regardless of the camera, just chronologically by year.

exiftool -d %Y '-directory</media/user/nikon-test-global${DateTimeOriginal'

or with:

exiftool -r -o DummyDir/ '-filename</media/user/nikon-test-global/${DateTimeOriginal}_${ImageSize}_${Model;}%-c.%le' -d '%Y.%m.%d-%H-%M-%S' . > exiftool -d %Y '-directory</media/user/nikon-test-global${DateTimeOriginal'

The command sorts roughly how I want it, but the photos get a number in each year folder from 0-x. Can the two commands be merged into one command so that I can copy, rename and globally number all photos?

Thanks in advance

P.

Title: Re: Sort photos by year, copy, rename by datecreate globally number with one command
Post by: StarGeek on January 28, 2025, 12:50:00 PM
Use the DateFmt helper function (https://exiftool.org//exiftool_pod.html#Helper-functions) and the hashtag version of the -n (--printConv) option (https://exiftool.org/exiftool_pod.html#n---printConv)

Test this to make sure it's right, then change Testname to Filename
exiftool -r -o DummyDir/ '-TestName</media/user/nikon-test-global/${DateTimeOriginal#;DateFmt('%Y')}/${DateTimeOriginal}_${ImageSize}_${Model;}%-c.%le' -d '%Y.%m.%d-%H-%M-%S' DIR
Title: Re: Sort photos by year, copy, rename by datecreate globally number with one command
Post by: AmirJK on January 30, 2025, 08:40:53 AM
Here is an improvement suggestion:
When I aggregate photos from the same event (e.g. a day in a trip, where I took photos a Nikon camera and a Pixel phone), I copy all the event's photos to one folder and run the renaming there. This requires running ExifTool once for each camera/phone. Not a big deal.
In the rename commands, after the date-time part, I add a short name of the device (e.g. ND5 for Nikon D500, P8 for Pixel 8, etc., as I don't need the full camera name as recorded in the metadata) and then the name of original photo, so I can easily correlate the renamed photo to the original one.

So I will get these new names:
2025-01-30_10_05_59-ND5-DSC_1234.JPG
2025-01-30_10_05_45-P8-PXL_20250130_100545287.jpg

I will post later the exact procedure that I use.