Sample Header Ad - 728x90

Bash for file processing

0 votes
2 answers
453 views
I am writing a bash script to move all images into a central file. I create the list of image files with: img_fil='/home/files/img_dump.txt' locate -i image | grep \.jpg > "$img_fil" locate -i image | grep \.jpeg >> "$img_fil" locate -i image | grep \.gif >> "$img_fil" locate -i image | grep \.tif >> "$img_fil" locate -i image | grep \.png >> "$img_fil" But when I start processing the dump file for this, most of the paths contain blanks so this does not work: while read -r fline do if [ ! -e "$fline" ]; then echo "F=> $fline" mv "$fline" "$img_dir" else fpath="$(dirname $fline)" fname="$(basename $fline)" echo "F=> $fname P=> $fpath" fi done The dirname and basename always parse at the blanks so will not process right. How do I get this to work?
Asked by OldManRiver (1 rep)
Feb 25, 2018, 09:17 PM
Last activity: Feb 25, 2018, 09:46 PM