Refactor sortimages.

This commit is contained in:
2020-01-19 12:21:07 +01:00
parent b638bf94f2
commit 4b22720c9e
+20 -7
View File
@@ -126,16 +126,30 @@ source $DOTCONFDIR/dotconf.sh
### Shell function definition
function _sortimages () {
SOURCE="$1"
TARGET_PREFIX="$2"
DRYRUN=$3
TARGET=${TARGET_PREFIX}".jpg"
if [ $(echo "$TARGET_PREFIX" | awk '{print length}') -ge 15 ]; then
echo mv $SOURCE $TARGET;
if [ $DRYRUN = 0 ]; then
mv $SOURCE $TARGET;
chmod 640 $TARGET;
fi
else
echo "Cannot read Exif information, skipping... $SOURCE"
fi
}
function sortimages () {
case $1 in
-d)
shift
for file in $@; do
DST=`identify -format "%[Exif:DateTimeOriginal]" $file | head -1 | awk '{print $1":"$2}' | awk -F':' '{print $1$2$3"-"$4$5$6}' | awk -F'.' '{print $1 }' | awk -F'::' '{print $1}'`
DST=`echo $DST.jpg`
echo mv $file $DST;
mv $file $DST;
chmod 640 $DST;
_sortimages $file $DST 0
done
;;
*)
@@ -144,11 +158,10 @@ function sortimages () {
echo " <file-selection> : for example *.JPG"
echo " <suffix> : rename to "'$date'"-'$time'-suffix.jpg"
echo " <options> : -d rename the files"
echo -n
echo
for file in $@; do
DST=`identify -format "%[Exif:DateTimeOriginal]" ${file} | head -1 | awk '{print $1":"$2}' | awk -F':' '{print $1$2$3"-"$4$5$6}' | awk -F'.' '{print $1 }' | awk -F'::' '{print $1}'`
DST=${DST}'.jpg'
echo mv ${file} ${DST};
_sortimages $file $DST 1
done
;;
esac