Rockbox Ports are now being developed for various digital audio players!
for img in `find . -name "*" | egrep *\.jpe?g$`do idout=`identify -verbose $img | grep -i interlace | grep -i none$` if [[ -z $idout ]] then echo "-------------------------" echo "$img is progressive" echo "....making copy of original with .prog extension" /bin/cp -f $img $img.prog echo "....converting to baseline" convert $img -interlace none $img echo "....done!" #else #echo "$img is non-progressive" fidone
IFS_ORIG=$IFS #save original IFS will restore at endset -f #Disable filename expansion (globbing).IFS=$'\n'for img in `find . -name "*" | egrep *\.jpe?g$`do idout=`identify -verbose $img | grep -i interlace | grep -i none$` if [[ -z $idout ]] then echo "-------------------------" echo "$img is progressive" echo "....making copy of original with .prog extension" /bin/cp -f $img $img.prog echo "....converting to baseline" convert $img -interlace none $img echo "....done!" #else #echo "$img is non-progressive" fidoneset +fIFS=$IFS_ORIG
Just for the record, newlines are perfectly valid in filenames, so that script is still breakable
If you're using bash, then you have two additional options. One is to use GNU or BSD find's -print0 option, together with bash's read -d '' option and a ProcessSubstitution:Code: [Select]while IFS= read -r -d '' file; do some command "$file"done < <(find . -type f -name '*.mp3' -print0)
while IFS= read -r -d '' file; do some command "$file"done < <(find . -type f -name '*.mp3' -print0)
#!/usr/bin/env bash function process_jpeg(){ img="$1" idout="$(identify -verbose "$img" | grep -i interlace | grep -i none)" if [[ -z "$idout" ]] then echo "-------------------------" echo "$img is progressive" echo "....making copy of original with .prog extension" /bin/cp -f "$img" "$img.prog" echo "....converting to baseline" convert "$img" -interlace none "$img" echo "....done!" fi}command -v identify >/dev/null 2>&1 || { echo >&2 "identify is required, but not installed. Aborting."; exit 1; };while IFS= read -r -d '' file; do process_jpeg "$file"; done < <(find "$PWD" -type f \( -iname "*.jpg" -o -iname "*.jpeg" \) -print0)
Page created in 0.139 seconds with 21 queries.