Created
June 16, 2019 18:10
-
-
Save ibressler/fbf3ab797bb4b15d181b9b1d36846e80 to your computer and use it in GitHub Desktop.
Rename iPhone pictures by embedded timestamp and associated MOV video files
This file contains hidden or 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
for fn in *.JPG; do | |
echo "=> $fn" | |
# get the timestamp from exif, format it accordingly | |
ts=$(exiv2 -g DateTimeOriginal $fn | awk '{ts=$(NF-1)"_"$NF; gsub(":","",ts); print ts}') | |
# retrieve the base name as well | |
basen=${fn%.*} | |
# rename the image, append its original name | |
mv -i "$fn" "${ts}_$basen.jpg" | |
# check if there is video file with the same name (live mode) | |
if [ -f "$basen.MOV" ]; then | |
# rename the video file to the same timestamp | |
mv -i "$basen.MOV" "${ts}_$basen.mov" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment