Syntax Help for changing dates from filenames

Started by Eambo, April 30, 2024, 08:10:17 AM

Previous topic - Next topic

Eambo

Hi folks - thanks in advance for any help you can offer.

I'm moving from Google Photos to self-hosted Immich, and takeout seems to have "lost" some of my metadata along the way.

I have around 1,500 files from April 19th 2024 or April 30th 2024 - which are incorrect. They should like this for example:

ExifTool Version Number         : 12.57
File Name                       : IMG_20170429_104842.jpg
Directory                       : .
File Size                       : 3.0 MB
File Modification Date/Time     : 2024:04:30 02:32:03+01:00
File Access Date/Time           : 2024:04:30 02:32:06+01:00
File Inode Change Date/Time     : 2024:04:30 02:32:03+01:00
File Permissions                : -rwxr-xr-x
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : OnePlus
Camera Model Name               : ONEPLUS A3003
Orientation                     : Rotate 90 CW
Software                        : OnePlus3-user 7.1.1 NMF26F 22 dev-keys
Modify Date                     : 2017:04:29 10:48:33
Exif Version                    : 0220
Date/Time Original              : 2017:04:29 10:48:42


I've been trying without luck to put together something that:

- Will look through all folders recursively
- Will find files with either a date of 19th or 30th of April 2024
- Will take the filename and replace the dates with that

Some complications:

- Some of the filenames are only YYYYMMDD format - no times
- There's quite a lot of folders to trawl through

I've tried some very basic attempts such as the following:

exiftool -if "$createdate eq '2017:04:29 10:48:42'" -T -FileName -DateTimeOriginal ./IMG_20170429_104842.jpg -v

But I get the error

Condition: syntax error - ./IMG_20170429_104842.jpg
-------- ./IMG_20170429_104842.jpg (failed condition)

Would anyone mind lending me their expertise on how I can find files with a certain date time recursively, and fix them with the filename or datetimeoriginal (as shown above which is correct, but immich doesn't pick it up).

Thank you, and sorry if this is a messy/complex ask!

StarGeek

What OS/shell?

If on Mac/Linux, swap single/double quotes, as double quotes around anything with a $ causes the shell to interpret it as a shell variable instead of an exiftool one.
* 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).

Eambo

Quote from: StarGeek on April 30, 2024, 11:35:26 AMWhat OS/shell?

If on Mac/Linux, swap single/double quotes, as double quotes around anything with a $ causes the shell to interpret it as a shell variable instead of an exiftool one.

That did the trick - I'm a recent windows to Mac convert and missed this. Thank you for your help!