diff options
author | Stijn Buys <ingar@telenet.be> | 2022-08-28 11:44:07 +0200 |
---|---|---|
committer | Stijn Buys <ingar@telenet.be> | 2022-08-28 11:44:07 +0200 |
commit | 7329ffa21452841d5c5ef56d4f9ba150417f6f50 (patch) | |
tree | 955b7c246039e7a019a3c338ed4e332ad3e86e9a /dcimrename |
Initial commit.
Diffstat (limited to 'dcimrename')
-rwxr-xr-x | dcimrename | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dcimrename b/dcimrename new file mode 100755 index 0000000..f04ae1e --- /dev/null +++ b/dcimrename @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Rename file to IMG_yyyyddmm_hhmmss.jpg using the EXIF timestamp." + echo "usage: $0 file1.jpg file2.jpg ..." + exit 0 +fi + +while [ ! -z "$1" ]; do + file="$1" + + if [ `basename "${file}" ".jpg"`".jpg" = "${file}" ]; then + + echo "renaming $file" + + # set file timestamp from exif data + exiftool "-DateTimeOriginal>FileModifyDate" "${file}" + + # get timestamp from file + #file_timestamp=`date -r "${file}" +"IMG_%Y%m%d_%H%M%S%2N"` + + file_timestamp=`date -r "${file}" +"IMG_%Y%m%d_%H%M%S"` + mv "${file}" "${file_timestamp}.jpg" + fi + + shift +done + |