Google Takeout Removed Date - Change based on folder name

Started by Spadez, February 05, 2020, 01:34:57 PM

Previous topic - Next topic

Spadez

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.

Spadez

Sorry - I can't delete this but I have found a way to easily rename it in OSX anyway.

Phil Harvey

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
...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 ($).

Spadez

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 /

Phil Harvey

ExifTool is very flexible about the input date/time format.  See FAQ 5 for details.

- 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 ($).

Phil Harvey

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
...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 ($).

Hubert

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.



Phil Harvey

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
...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 ($).

Hubert

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:



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



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  :)



Phil Harvey

...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 ($).