Most efficient way to rename files based on exif data.

Started by clem, December 18, 2024, 01:35:11 AM

Previous topic - Next topic

clem

I'd like to get a command for exiftool to:

append to the beginning and if necessary to the end without deleting the original filename some metadata information -

Case 1)

In the case where the file has a filetype extension I'd like to add to the beginning of the file

YYYY-MM-DD - HHMMSS - W - H - <original name>

so Year, Month, Day, Hour Minute Second - Width - Height - original name.

2020-02-29 - 232221 - 320 - 480 - 00c9134d88599dada0302d680d82748131971e31.jpg

Case 2)

And for even more fun, if the file has no extension, to add an all CAPS extension with a preceding string - ftyp.FILETYPE

2019-04-31 - 053258 - 1792 - 828 - 00d19996e6f9976aa91867ea55c20a6184a25bf4 - ftyp.MOV

suggestions appreciated,

thanks :-)


StarGeek

The basic command would be something like
exiftool -d "%Y-%m-%d - %H%M%S" "-Filename<$DateTimeOriginal - $ImageWidth - $ImageHeight - %f.%e" /path/to/files/

But it depends upon the file type. Not all files will have a DateTimeOriginal tag, especially in the case of videos. You'll have to double-check what date/time tags are available with
exiftool -time:all -G1 -a -s /path/to/files/

For the files without an extension
exiftool -ext "" -d "%Y-%m-%d - %H%M%S" "-Filename<$DateTimeOriginal - $ImageWidth - $ImageHeight - %f  - ftyp.$FileTypeExtension" /path/to/files/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

clem

Excellent. That works well for well behaved JPGs... Thank you.  :)

I'm presuming that if I want to get exiftool to go diving through nested directories I add a -r switch?

What is the best way to deal with files that have no exif tags for date and only have as dates information from  file creation / modification. These files have minimal data and I'll sort them by their file creation dates instead when added as a prefix to the original filename in addition to the pixel dimensions.

ExifTool Version Number         : 13.05
File Name                       : 00c9134d88599dada0302d680d82748131971e31.jpg
Directory                       : .
File Size                       : 3.9 kB
File Modification Date/Time     : 2020:06:11 09:10:47-07:00
File Access Date/Time           : 2024:12:19 23:20:32-08:00
File Inode Change Date/Time     : 2024:12:19 23:20:32-08:00
File Permissions                : -rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.02
Resolution Unit                 : inches
X Resolution                    : 72
Y Resolution                    : 72
Image Width                     : 75
Image Height                    : 75
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 75x75
Megapixels                      : 0.006

StarGeek

Quote from: clem on December 20, 2024, 02:38:01 AMWhat is the best way to deal with files that have no exif tags for date and only have as dates information from  file creation / modification. These files have minimal data and I'll sort them by their file creation dates instead when added as a prefix to the original filename in addition to the pixel dimensions.

See Note #1 under the -TAG[+-^]=[VALUE] option.
QuoteMany tag values may be assigned in a single command. If two assignments affect the same tag, the latter takes precedence

You would duplicate the rename that uses DateTimeOriginal and change the tag to FileCreateDate or FileModifyDate. You would put that before the DateTimeOriginal rename.

See example command #12 on the Writing "FileName" and "Directory" tags page

The result is that if DateTimeOriginal doesn't exist in the file, it will fall back and use the earlier rename. And since FileCreateDate/FileModifyDate, that will always succeed.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype