Originally Posted by
MechaMechanism
Here is my command. It does not work. Possibly because of the dollar signs? I am not to familiar with stringing commands together very well. I pieced this together based on tidbits from all over the web. It is calling up the Imagemagick command convert to do operations on 39 PNG files and output the new files in a separate dir.
Code:
find ./ -name *.png -exec convert {} -shave 50x50 -bordercolor white -border 1x1 -fuzz 70% -trim /home/nate/Pictures/trim/{} \;
The problem is that {} in the find command contains the full path down to wherever the png file is. For example something like
Code:
/home/nate/Pictures/vacation/2014-bermuda/scuba01.png
The command is trying to write an output file to something like
Code:
/home/nate/Pictures/trim/./home/nate/Pictures/vacation/2014-bermuda/scuba01.png
which fails because several directory levels are missing
What you need is commands that use the full path of the png files for input, but only use the filename part for output. Try this:
Code:
while IFS= read -r -d '' file; do
filename=`basename "$file"`
convert "$file" -shave 50x50 -bordercolor white -border 1x1 -fuzz 70% -trim "/home/nate/Pictures/trim/$filename"
done < <(find ./ -name "*.png" -print0)
This syntax makes the find command print null delimited lines for each png found enabling the while loop to handle filenames that contain spaces or special characters.
Bookmarks