#sätt alla bilder i alla undermappar till 500 * 700 och konvertera dom till png OUTROOT="./images_png"; ROOT="./images"; find "$ROOT" -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.bmp' -o -iname '*.png' \) -print0 | while IFS= read -r -d '' f; do rel="${f#"$ROOT"/}"; out="$OUTROOT/${rel%.*}.png"; mkdir -p "$(dirname "$out")"; read -r w h < <(magick "$f" -auto-orient -format "%w %h" info:); if [ "$w" -gt "$h" ]; then magick "$f" -auto-orient -rotate 90 -resize '500x700!' -strip "$out"; else magick "$f" -auto-orient -resize '500x700!' -strip "$out"; fi; done #Kolla så allt blev rätt echo "OK: $(find ./images_png -type f -iname '*.png' -print0 | xargs -0 -I{} magick identify -ping -format "%w %h\n" "{}" | awk '$1==500 && $2==700{ok++} $1!=500 || $2!=700{bad++} END{print ok+0}') BAD: $(find ./images_png -type f -iname '*.png' -print0 | xargs -0 -I{} magick identify -ping -format "%w %h\n" "{}" | awk '$1!=500 || $2!=700{bad++} END{print bad+0}')" #rotera liggande kort 90 grader ROOT="/sökväg/till/rotmappen"; find "$ROOT" -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.bmp' -o -iname '*.png' \) -print0 | while IFS= read -r -d '' f; do read -r w h < <(magick identify -ping -format "%w %h" -- "$f"); if [ "$w" -gt "$h" ]; then magick mogrify -auto-orient -rotate 90 -- "$f"; fi; done ##nano i crontab printf '\nexport VISUAL=nano\nexport EDITOR=nano\n' >> ~/.bashrc && source ~/.bashrc #enable cron sudo systemctl enable --now cronie.service