Yesterday I took a bunch of pictures but I forgot to change the timezone in my camera. Now all pictures have wrong modification date.
I want to change modification date of all files in a specific directory to minus 10 hours.
#!/bin/sh
for i in /Users/slick/Desktop/100D5200/*; do
touch -r "$i" -d '-10 hour' "$i"
done
When I run this script in OSX, I get
touch: illegal option -- d usage: touch [-A [-][[hh]mm]SS] [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...
What am I doing wrong?
You're using the options for GNU touch. You can install it in OS X using Homebrew in OS X:
$ brew install coreutils
Then it will be available under the name gtouch instead of touch:
#!/bin/sh
for i in /Users/slick/Desktop/100D5200/*; do
gtouch -r "$i" -d '-10 hour' "$i"
done
However, the -d '10 hour' will not move the timestamp back ten hours, but set the timestamp to the current time minus ten hours. If you want to offset the time stamps, you will have to do the arithmetics for each file.
Furthermore, what you actually want might be to change the EXIF data of the pictures, which would need another tool than touch altogether.
Below commands solved my problem:
exiftool "-AllDates-=10" /Users/slick/Desktop/100D5200
exiftool "-DateTimeOriginal>FileModifyDate" /Users/slick/Desktop/100D5200
Obviously before do
brew install exiftool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With