Created
May 19, 2018 23:11
-
-
Save sh78/ce8462d38e587ab8e3ceb81e2c723435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# write date created to date modified | |
## `GetFileInfo -d $file` gives us 01/28/2007 22:56:00 | |
# we need "YYYYMMDDhhmm" for `touch -mt` to set modification time | |
set tally 0 | |
for file in (find ./ -maxdepth 1) | |
set dateString "" # final result goes here | |
set cuts "7-10" "1-2" "4-5" "12-13" "15-16" # string indices to extract | |
for cut in $cuts | |
set dateString $dateString(GetFileInfo -d $file | cut -c $cut) | |
end | |
touch -mt$dateString $file # update mod date | |
set tally (math $tally + 1) # deceminate sitrep | |
echo "Modified "$tally" files..." | |
end | |
# replace file system modified date with exif CreationDate | |
## `exiftool` doesn't write to wmv's, so without MediaCreateDate Google Photos uses | |
## file system's modified date, which is wrong. | |
for file in ./*.wmv | |
set dateString (exiftool -s -s -s -creationdate $file | sed "s/://g" | sed "s/\ //g" | sed "s/Z//g") | |
set dateString (echo $dateString | cut -c 1-12) | |
touch -mt$dateString $file | |
echo $file" modified date is now "$dateString | |
end | |
# replace file system modified date with exif media create date | |
for file in ./*.3gp | |
set dateString (exiftool -s -s -s -mediacreatedate $file | sed "s/://g" | sed "s/\ //g" | sed "s/Z//g") | |
set dateString (echo $dateString | cut -c 1-12) | |
touch -mt$dateString $file | |
echo $file" modified date is now "$dateString | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment