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 |
Initial commit.
-rw-r--r-- | README.md | 73 | ||||
-rwxr-xr-x | dcimdirsort | 24 | ||||
-rwxr-xr-x | dcimrename | 28 | ||||
-rwxr-xr-x | dcimtimestamp | 22 |
4 files changed, 147 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..5833228 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# DCIMTOOLS + +A collection of shell scripts to manage the JPEG images produced by digital cameras, phones and other devices. + +## Scripts + +### dcimrename + + +```dcimrename file1.jpg file2.jpg ...``` + +Will read the EXIF timestamp from the jpg files on the command line and alter the file's modification time accordingly. Renames to file using the format IMG_yyyyddmm_hhmmss.jpg. + +Note that the file extension has to be ```.jpg``` in lower case, other extensions are ignored. You can preprocess your files with the linux ```rename``` utility. + +For example, if your files have their extension in upper case: + +```rename .JPG .jpg *.JPG``` + +Also note the file name format has a resolution of one second. If your pictures' timestamp differ by less then a second, files will be overwritten. In general, the script does not check if files already exist and mercilessly overwrites them. + +### dcimdirsort + +```dcimdirsort``` + +Moves files into a subdirectory for each day, based on the file's modification time. + +For each file on the command line, it's file modification time will be read. If it doesn't exist already, a subdirectory with the format ```yyyy-mm-dd``` will be created and the file will be moved into it. + +### dcimtimestamp + +```dcimtimestamp file1.jpg file2.jpg ...``` + +Writes the files modification time to the EXIF timestamp. Can be used to correct broken or missing picture timestamps. The same .jpg file extension rule applies. + +## Workflow + +#### Prepare +Copy all the picture files you want to manage in a single directory. Make sure they have a valid and correct EXIF timestamp. Make sure you do not have any pictures taken less then a second apart. + +#### Rename +Make sure all the pictures have the .jpg extension. If they don't, rename them accordingly. + +Run ```dcimrename *.jpg``` + +#### Move to subdirectories + +Run ```dcimdirsort *.jpg``` + + +## Notes + +Obviously, there is room for improvement. Ideally I'd write a C program and roll all functionallity into one program. Add additional checks and customization options etc... + +## License + +dcimtools copyright (c) Stijn "Ingar" Buys, 2022 <ingar@telenet.be> + +dcimtools is available under the terms and conditions of the Do What The Fuck You Want To Public License + +#### DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE +Version 2, December 2004 + +Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> + +Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. + +#### DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + +##### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +* You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/dcimdirsort b/dcimdirsort new file mode 100755 index 0000000..5f5a7d1 --- /dev/null +++ b/dcimdirsort @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Move files into a directory per day, based on file modification time" + echo "usage: $0 file1 file2 ..." + exit 0 +fi + +while [ ! -z "$1" ]; do + file="$1" + + file_date=`date -r "${file}" +"%Y-%m-%d"` + + if [ ! -d "${file_date}" ]; then + mkdir "${file_date}" + fi + + echo "Moving ${file} to ${file_date}/" + + mv "${file}" "${file_date}/" + + shift +done + 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 + diff --git a/dcimtimestamp b/dcimtimestamp new file mode 100755 index 0000000..d67ab20 --- /dev/null +++ b/dcimtimestamp @@ -0,0 +1,22 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Set file modification time to 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 "settimg modification time for $file" + + # set file timestamp from exif data + exiftool "-DateTimeOriginal>FileModifyDate" "${file}" + fi + + shift +done + |