Skip to content

Instantly share code, notes, and snippets.

@shenwei356
Last active September 27, 2023 02:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shenwei356/dfeeb0f0386be0d7f7fbdf6f14be08ee to your computer and use it in GitHub Desktop.
Save shenwei356/dfeeb0f0386be0d7f7fbdf6f14be08ee to your computer and use it in GitHub Desktop.
Adding create time to image/video files
#!/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