1

I have 1,500-some Facebook photos all showing with the same date as they come from a data download.

Through the magic of regular expressions, I have generated a TSV file where each row has the filename on the left and the correct timestamp on the right, example being:

13170030_982552864458_69609533_o_982552864458.jpg{tab}7/29/2017 4:47:23 PM

How would I go about batch changing the taken/modified/created dates for these files in Automator or Shortcuts?

I also have a Windows PC so if this isn't possible with MacOS but you know of a solution using Powershell or a COTS Windows product off-of-the-top-of-your-head, that's fine with me.

3
  • 1
    Does your regex magic allow to create timestamps in 24 hour format? It would simplify the batch renaming.
    – nohillside
    Commented Apr 14, 2022 at 13:00
  • 1
    I'm going to suggest that you look into Phil Harvey's exiftool, platform agnostic and written in Perl.
    – fd0
    Commented Apr 14, 2022 at 13:12
  • @fd0, please feel free to add this as an answer so that I can mark it as the solution. I did use exiftool with success. Thanks! Commented Apr 25, 2022 at 17:08

1 Answer 1

0

There is a built-in command on macOS called SetFile:

% SetFile 
Usage: SetFile [option...] file...
    -a attributes     # attributes (lowercase = 0, uppercase = 1)*
    -c creator        # file creator
    -d date           # creation date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -m date           # modification date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -P                # perform action on symlink instead of following it
    -t type           # file type
...

So you could run a short command line like:

while IFS=$'\t' read -r filename created
do
    SetFile \
        -d "$(date -jf "%m/%d/%Y %r" "$created" +"%D %T")" \
        "$filename"
done < mylist.tsv 

The date format %m/%d/%Y %r is just what I guessed your format is, based on the 7/29/2017 4:47:23 PM example in the question.

And the default Created, Modified dates seem to be the only metadata about time stored in photos taken with iPhones (there is no "time taken" metadata).

I checked all the metadata on the iPhone photo using mdls

mdls – lists the metadata attributes for the specified file
mdls 13170030_982552864458_69609533_o_982552864458.jpg

would show you the metadata on your image.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .