Loop through file extension Annotate add EXIF Rename and Copy
This script, reads user input from an entry like filename.jpg
it creates a directory inside the current directory. Then renames the file and adds the files EXIF data it then copies the original file to the directory that was just created.
Using convert from imagemagick
I am trying to figure out a loop through the directory of like 100 files by file extension like(.*jpg, *png,*jpeg), automatically rename, add EXIF data, create new directory(inside directory) if not exist, copy originals to new directory. With really no user input other than extension. For these certain extensions.
#!/bin/bash
ls -XI "*.sh" |sort -g -r
echo
echo "Enter Image name with file extension"
read MGNM
newdir=${PWD##*/}
LBLNM=`identify -format "%[EXIF:DateTime]" $MGNM`
echo "${LBLNM[@]}"
mkdir -vp $newdir
convert $MGNM -background Khaki -pointsize 100 label:"$LBLNM" -gravity Center -append ADDEDPREFIX-$MGNM
mv -v $MGNM $newdir/
echo
ls -XI "*.sh" |sort -g -r
echo
ls -XI "*.sh" $newdir/|sort -g -r
Possibly add the resize, after the exif data is added, then copy originals to one directory inside of the working directory?
mogrify -path $newdir/ -resize 50% -quality 80 *.JPG
If that works for you already and all you want is to automate it, then most likely what you need is to put it all inside a shell loop … Here is an example:
for f in {*.jpg,*.jpeg,*.png}; do
newdir="${PWD##*/}"
LBLNM=$(identify -format "%[EXIF:DateTime]" "$f")
mkdir -vp "$newdir"
convert "$f" -background Khaki -pointsize 100 label:"$LBLNM" -gravity Center -append ADDEDPREFIX-"$f"
mv -v "$f" "$newdir"/
mogrify -path "$newdir"/ -resize 50% -quality 80 "$f"
done
… that will loop over all files in the current working directory with glob patterns *.jpg
, *.jpeg
and *.png
and do operations on them as you wish.