Last active
October 19, 2022 23:35
-
-
Save victorlin/7a303a3aaeb65cfa4f4bd534a118eb58 to your computer and use it in GitHub Desktop.
shell scripts to organize and modify scanned images from Epson FastFoto FF-680W
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 f in *.jpg; do | |
date="${f:0:10}" | |
if ! [ -d "${date}" ]; then | |
echo "creating folder ${date}" | |
mkdir "${date}" | |
fi | |
echo "moving ${f}" | |
mv ${f} ${date} | |
done |
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
# use exiftool to change image date of all files to date in directory. | |
# time set to 12:00. | |
# directory name must follow pattern "YYYY-mm-dd". | |
# parameter $1: directory path | |
function change_img_dates { | |
directory=$1 | |
dateFmt="${directory//-/:}" | |
allDatesStr="${dateFmt} 12:00:00" | |
# exiftool -AllDates="${allDatesStr}" ${directory}/*.jpg -overwrite_original | |
exiftool -time:all="${allDatesStr}" ${directory}/*.jpg -overwrite_original | |
} | |
# keep files that match `keep_mattern` | |
# then stash files matching `stash_pattern` into new folder `stash_dir`. | |
# operates on current directory. | |
function move_orig_to_folder { | |
keep_pattern="*_a.jpg" | |
stash_pattern="*.jpg" | |
stash_dir="original" | |
keep_dir="tmp" | |
if [ -d ${stash_dir} ]; then | |
echo "Already moved files. Skipping." | |
return | |
fi | |
echo "Keeping files matching ${keep_pattern}." | |
mkdir ${stash_dir} ${keep_dir} | |
mv ${keep_pattern} ${keep_dir} | |
mv ${stash_pattern} ${stash_dir} | |
mv ${keep_dir}/* . | |
rm -r ${keep_dir} | |
} | |
for D in *; do | |
# per folder | |
if [ -d "${D}" ]; then | |
echo "${D}" | |
change_img_dates ${D} | |
pushd ${D} > /dev/null | |
move_orig_to_folder | |
popd > /dev/null | |
fi | |
done |
@davidmerrick awesome, glad it works for you! Looking back at this, it seems unclear how files are supposed to be organized without a README. Hope it wasn't too hard to figure out!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this @victorlin! Just got one of these scanners to digitize some old photos and was about to write these scripts myself.