Renaming with missing tags

Started by Tim09G, October 30, 2019, 01:50:20 PM

Previous topic - Next topic

Tim09G

Hello community!

I'm pretty new to ExifTool and am having trouble with a project. I'm trying to rename a batch of pictures and .mov files to the date they were created. The files go back to around 2002 so some tags are missing for a lot of the files. Specifically what I'm trying to do is get ExifTool to rename the title of the file to the CreationDate if it exists, CreateDate if it doesn't, and finally the FileModifyDate if neither exist.

I've been doing this manually up until now. Having ExifTool rename to the CreationDate, then the Create date on the ones that didn't change, and finally the FileModifyDate for the ones that were still untouched. I'm about to break into two completely unorganized 2 tb drives and an automated process would make this much simpler.

From what I understand The last tag in the series takes precedence. But no matter what I try to do ExifTool isn't accepting my code. Can anyone give some advice or tips on what the code should look like?

Phil Harvey

It sounds like you have the right idea by copying the title from all 3 tags, with the highest priority one last.  If you show us your command we can show you what you are doing wrong.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Tim09G

Sure thing!

I have tried a lot of small alterations, but I think this one is the closest to correct:

exiftool -d '%Y_%m_%d_%H_%M' \ '-filename<${FileModifyDate;}.%le' \ '-filename<${CreateDate;}.%le' \ '-filename<${CreationDate;}.%le' \ -r /path

As I said I'm very new to this. I am sure there is a lot wrong with that. If there is anywhere specific you think I should read in the command-line documentation, I would be happy to do that. I am also on Mac if that is significant.

StarGeek

That command looks correct, except for the backslashes.  Are they needed?  AFAIK, all they're doing is escaping the following space.

In what way does that command not work?  What is the output after running that command.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Tim09G

Exiftool is looking at each separate item as an item it needs to change if that makes sense. Here is the output:


Charless-MacBook-Air:~ Kenton$ exiftool -d '%Y_%m_%d_%H_%M' \ '-filename<${FileModifyDate;}.%le' \ '-filename<${CreateDate;}.%le' \ '-filename<${CreationDate;}.%le' \ -r /Volumes/ADATA\ HD650/Organized/Jenny\ Photos\ May\ 2018/2017-12/IMG_0314.JPG
Error: File not found -  -filename<${FileModifyDate;}.%le
Error: File not found -  -filename<${CreateDate;}.%le
Error: File not found -  -filename<${CreationDate;}.%le
Error: File not found -  -r
======== /Volumes/ADATA HD650/Organized/Jenny Photos May 2018/2017-12/IMG_0314.JPG
ExifTool Version Number         : 11.74
File Name                       : IMG_0314.JPG
Directory                       : /Volumes/ADATA HD650/Organized/Jenny Photos May 2018/2017-12
File Size                       : 2.1 MB
File Modification Date/Time     : 2017_12_01_11_35
File Access Date/Time           : 2019_10_30_00_00
File Inode Change Date/Time     : 2017_12_01_11_35
File Permissions                : rwxrwxrwx
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 6s
Orientation                     : Rotate 90 CW
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 11.1.2
Modify Date                     : 2017_12_01_18_35
Y Cb Cr Positioning             : Centered
Exposure Time                   : 1/15
F Number                        : 2.2
Exposure Program                : Program AE
ISO                             : 1250
Exif Version                    : 0221
Date/Time Original              : 2017_12_01_18_35
Create Date                     : 2017_12_01_18_35
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/15
Aperture Value                  : 2.2
Brightness Value                : -3.741205345
Exposure Compensation           : 0
Metering Mode                   : Spot
Flash                           : Off, Did not fire
Focal Length                    : 4.2 mm
Subject Area                    : 3166 1067 753 756
Run Time Flags                  : Valid
Run Time Value                  : 298775056050958
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : -0.010668242 -1.000693963 -0.04490788703
Sub Sec Time Original           : 132
Sub Sec Time Digitized          : 132
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 29 mm
Scene Capture Type              : Standard
Lens Info                       : 4.15mm f/2.2
Lens Make                       : Apple
Lens Model                      : iPhone 6s back camera 4.15mm f/2.2
Compression                     : JPEG (old-style)
Thumbnail Offset                : 1742
Thumbnail Length                : 8292
XMP Toolkit                     : XMP Core 5.4.0
Region Area Y                   : 0.29500000000000004, 0.153, 0.75849999999999995, 0.63200000000000001
Region Area W                   : 0.033000000000000029, 0.034999999999999976, 0.036999999999999977, 0.035000000000000031
Region Area X                   : 0.39150000000000001, 0.45450000000000002, 0.41549999999999998, 0.58549999999999991
Region Area H                   : 0.043999999999999984, 0.045999999999999985, 0.049000000000000044, 0.046000000000000041
Region Area Unit                : normalized, normalized, normalized, normalized
Region Type                     : Face, Face, Face, Face
Region Extensions Angle Info Yaw: 0
Region Extensions Angle Info Roll: 270
Region Extensions Confidence Level: 1000
Region Extensions Time Stamp    : 7170591745639
Region Extensions Face ID       : 7
Region Applied To Dimensions H  : 3024
Region Applied To Dimensions W  : 4032
Region Applied To Dimensions Unit: pixel
Image Width                     : 4032
Image Height                    : 3024
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Run Time Since Power Up         : 3 days 10:59:35
Aperture                        : 2.2
Image Size                      : 4032x3024
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 7.0
Shutter Speed                   : 1/15
Create Date                     : 2017_12_01_18_35
Date/Time Original              : 2017_12_01_18_35
Thumbnail Image                 : (Binary data 8292 bytes, use -b option to extract)
Circle Of Confusion             : 0.004 mm
Field Of View                   : 63.7 deg
Focal Length                    : 4.2 mm (35 mm equivalent: 29.0 mm)
Hyperfocal Distance             : 1.82 m
Light Value                     : 2.5
    1 image files read
    4 files could not be read


The -r was unnecessary in that pathway, but it gives the same errors either way.

And you are probably correct on the backslashes. I only included them because it seemed that most people doing this had them. So not a very good reason.

StarGeek

The commands that you saw like that, were they split into separate lines?  For example, something like:
exiftool -d '%Y_%m_%d_%H_%M' \
'-filename<${FileModifyDate;}.%le' \
'-filename<${CreateDate;}.%le' \
'-filename<${CreationDate;}.%le' \
-r /path


I could be wrong (I don't use bash) but I believe that's a signal to bash that even though the text is on separate lines, it's meant to be processed as a single line.

What happens if you try the command without the backslashes?
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Hayo Baan

Quote from: StarGeek on October 30, 2019, 03:02:39 PM
I could be wrong (I don't use bash) but I believe that's a signal to bash that even though the text is on separate lines, it's meant to be processed as a single line.

That is correct.
Hayo Baan – Photography
Web: www.hayobaan.nl

Tim09G

Wow. StarGeek you are a godsend. You and Hayo Baan were on it. It was the backslashes. I just did a couple folders so I could watch, and they seem to have come out perfectly. I'll find out for sure a bit later tonight.

The only other question I have is if I edit all of the commands to

'-filename<${FileModifyDate;}%+3c.%le'


Would that be the correct way of adding the copy number command? (the %+3c)
Or would you still want to do the %%-c or something similar?

StarGeek

Quote from: Tim09G on October 30, 2019, 03:49:45 PM
The only other question I have is if I edit all of the commands to

'-filename<${FileModifyDate;}%+3c.%le'


Would that be the correct way of adding the copy number command? (the %+3c)

Yes, that would rename the files to
2019_10_30_10_00.mp4
2019_10_30_10_00_001.mp4
2019_10_30_10_00_002.mp4
etc

QuoteOr would you still want to do the %%-c or something similar?

You would double the percent signs if you moved the %c into the date format string.  The filename/path/extension/copy (%f/%d/%e/%c) %variables need the % sign doubled if they are included in the date string.  All these would be equivalent
exiftool -d '%Y_%m_%d_%H_%M' '-filename<${FileModifyDate;}%+3c.%le'
exiftool -d '%Y_%m_%d_%H_%M%%+3c' '-filename<${FileModifyDate;}.%le'
exiftool -d '%Y_%m_%d_%H_%M%%+3c.%%le' '-filename<${FileModifyDate;}'

Also, the trailing semicolon after FileModifyDate can be removed for these commands.  That format (${TAG;}) is used to remove characters that might cause problems in filenames / \ ? * : | " < > NULL  It is most often used for variables like Make and Model which often include such characters.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Tim09G

Interesting. I had no idea. That's perfect though. I owe you a bunch!

Thank You!