Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Think it's just replace the mdls stuff with exiftool:

Code:
touch -t $(date -j -f "%Y%m%d%H%M" -v-6H $(/usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M.%S" -s3 "$f")) "$f"

Or break it out:

Code:
dstr=$(date -j -f "%Y%m%d%H%M" -v-6H $(/usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M.%S" -s3 "$f"))
touch -t $dstr $f
 
  • Like
Reactions: Endeavor444
Thank you so much for you fast answer @NoBoMac, really appreciate it!

I tried both of your codes but got error messages..

I asked a friend and he said it's not 2022 anymore and that I should ask ChatGPT haha

This code works to modify both creation and modification date with changing the hour with a number before H, via automator:

Code:
# Loop through all the video files passed as arguments
for f in "$@"
do
    # Extract Create Date using exiftool
    createDate=$(/usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M.%S" -s3 "$f")

    # Calculate new date by adding +/- with a number before H
    newDate=$(date -j -v+8H -f "%Y%m%d%H%M.%S" "$createDate" +"%Y%m%d%H%M.%S")

    # Update both creation and modification dates using touch
    touch -t "$newDate" "$f"
done
 
  • Like
Reactions: NoBoMac
Yeah, dropped the + for date format and had the seconds field missing for date command when I cut/pasted.
 
Last edited:
For clarity, I tried your new code in Automator:

Code:
for f in "$@"
do
   touch -t $(date -v+8H +"%Y%m%d%H%M" $(/usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M" -s3 "$f")) "$f"
done


And I get this Error Message 😅:

Screenshot 2023-08-17 at 01.07.47.png
 
Yeah, typo-ed again.

Code:
touch -t $(date -j -v+8H -f "%Y%m%d%H%M.%S" $(/usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M.%S" -s3 "$f") +"%Y%m%d%H%M.%S") "$f"

Code:
% ls -l "$f"
-rw-r--r--@ 1 myid  staff  4429318 Aug 16 16:04 IMG_1417.jpeg
% /usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M" -s3 "$f"
202306172121
% touch -t $(date -j -v+8H -f "%Y%m%d%H%M.%S" $(/usr/local/bin/exiftool -CreateDate -d "%Y%m%d%H%M.%S" -s3 "$f") +"%Y%m%d%H%M.%S") "$f"
% ls -l "$f"
-rw-r--r--@ 1 myid  staff  4429318 Jun 18 05:21 IMG_1417.jpeg
 
Last edited:
  • Love
Reactions: Endeavor444
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.