ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Spadez on February 05, 2020, 01:34:57 PM

Title: Google Takeout Removed Date - Change based on folder name
Post by: Spadez on February 05, 2020, 01:34:57 PM
Hi,

Long story short, Google Takeout has completely screwed up some of my photos exif data, putting many of them for 31 Dec 2019 not their correct date. The real date is not listed against any attribute. This is on thousands of photos.

Thankfully, for many of them it has put them in folder names of the correct date, i.e 2007-11-25

The closest helpful thread I can find is this one:
https://exiftool.org/forum/index.php?topic=3807.0

It seems to suggest this command:
exiftool '-datetimeoriginal<${directory} 00:00:00' -r /Ray/Desktop

However my folders are not in the format YYYY\MM\DD. Is there a way I can do this with the existing folder structure without having to name them all, as there are hundreds. You will notice my folders are structured with dashes not slashes.
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Spadez on February 05, 2020, 01:43:12 PM
Sorry - I can't delete this but I have found a way to easily rename it in OSX anyway.
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Phil Harvey on February 06, 2020, 08:22:46 AM
The ExifTool command you gave will also work with your directory structure.

It may be useful to others if you post details about your OSX solution.

- Phil
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Spadez on February 06, 2020, 12:41:34 PM
Oh really? So it doesn't have to be with slashes, the date can be with dashes?

My solution in OSX was to do Cmd-F and then find all using the "-" char, and then select all the folders it returns, right click, rename, and then replace - with /
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Phil Harvey on February 06, 2020, 12:50:16 PM
ExifTool is very flexible about the input date/time format.  See FAQ 5 (https://exiftool.org/faq.html#Q5) for details.

- Phil
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Phil Harvey on February 06, 2020, 12:53:41 PM
About your OS X solution:  Note that this would have replaced the "-" characters with ":".  NOT "/" as you expected, since "/" is not a legal character in a file name, so OS X uses ":" instead, but shows it as "/".

- Phil
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Hubert on February 07, 2020, 04:39:50 AM
Um... with respect, the colon is an illegal character for macOS file names (it's used as a path separator). As far as I'm aware the forward slash and backslash are fine (grab attached). But forward slashes would need to be escaped in any scripts or Terminal commands. Hyphens would be a better bet IMHO.

EDIT: Terminal escapes the slash character as "\:" (no quotes). All the more reason to avoid colons and any sort of slash in a file name if you want to preserve your sanity.


Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Phil Harvey on February 07, 2020, 07:31:30 AM
To be more specific:  As far as the BSD subsystem and ExifTool are concerned, OS X forward slashes show up as colons in file names.  Try doing an "ls" on an OS X file containing forward slashes.

This isn't just the Terminal escaping the slash.

- Phil
Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Hubert on February 07, 2020, 09:01:43 AM
I think I misinterpreted this:

Quote from: Phil Harvey on February 06, 2020, 12:53:41 PM

since "/" is not a legal character in a file name, so OS X uses ":" instead, but shows it as "/".


I assumed, quite wrongly, that you were implying that ":" is a legal character in a macOS file name.

But...

Quote from: Phil Harvey on February 07, 2020, 07:31:30 AM
  Try doing an "ls" on an OS X file containing forward slashes.

Yes indeed - the slash in the file name shows up as an unescaped colon.


However, and somewhat OT...

(Hope these image links work...)


At OSX user interface level, if I drag and drop a file with a slash in the name from Finder into Terminal, then the slash is replaced with an escaped colon:

(https://i.imgur.com/hN0vBT7.png)

And at Finder level it is not possible to use colons in macOS file or folder names:

(https://i.imgur.com/40jQJrL.png)

The whole colon vs slash thing is, I believe, an historical kludge on the part of OSX to maintain compatibility with the "Classic" Mac OS's.

Thanks as ever for sorting it all out as far as Exiftool is concerned  :)


Title: Re: Google Takeout Removed Date - Change based on folder name
Post by: Phil Harvey on February 07, 2020, 09:29:22 AM
Yes.