Last active
September 27, 2023 02:59
-
-
Save shenwei356/dfeeb0f0386be0d7f7fbdf6f14be08ee to your computer and use it in GitHub Desktop.
Adding create time to image/video files
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
#!/bin/sh | |
while read file; do | |
if [[ $string =~ .*=.* ]]; then | |
continue | |
fi | |
t=$(exiftool "$file" \ | |
| grep "^Create Date" | head -n 1 \ | |
| sed -r "s/\s+/ /g" | cut -d " " -f 4 \ | |
| sed "s/:/-/g"); | |
d=$(dirname $file) | |
b=$(basename $file) | |
mv "$file" "$d/$t=$b" | |
done | |
# example | |
# | |
# $ ls IMG* | |
# IMG_3286.MOV IMG_5441.JPG | |
# | |
# $ ls IMG* | add-timestamp-for-media-file.sh | |
# $ ls *=* | |
# '2016-08-15=IMG_5441.JPG' '2018-03-03=IMG_3286.MOV' | |
# | |
# https://github.com/shenwei356/brename | |
# rename anyfile except for .AAE files | |
# brename -R -l -F AAE$ -p . | add-timestamp-for-media-file.sh | |
# | |
# | |
# faster with parallel or rush https://github.com/shenwei356/rush | |
# ls * | rush 'echo {} | add-timestamp-for-media-file.sh' --eta | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment