opencand/OpenCand.API/jpg-normalize.sh
2025-06-02 16:47:24 -03:00

33 lines
825 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
cd ./fotos_cand
COUNT=0
shopt -s nocaseglob
# Loop through all folders
for dir in */; do
# Change into the directory
cd "$dir" || continue
# Loop over every “.jpeg” (or “.JPEG”):
for f in *.jpeg; do
# “${f%.[jJ][pP][eE][gG]}” strips off the .jpeg/.JPEG suffix
base="${f%.[jJ][pP][eE][gG]}"
newfile="${base}.jpg"
# If theres already a .jpg with the same “base,” decide what to do:
if [ -e "$newfile" ]; then
echo "Skipping $f$newfile (target exists)"
# you could `rm "$f"` or move it to a backup folder here if you prefer
else
mv -v "$f" "$newfile"
fi
done
# Change back to the parent directory
cd ..
done
shopt -u nocaseglob
# Print a message indicating completion
echo "Normalization complete. Processed $COUNT files."