Wednesday, June 23, 2004


rm -f conversion && tree -fi | grep .tif | awk -F. '{print


> "convert@@@."$2"."$3"@@@png:."$2".png"}' | sed -e 's/ /\\ /g' | sed -e


> 's/@@@/ /g' | sed -e 's/(/\\(/g' | sed -e 's/)/\\)/g' > conversion &&


> chmod 755 conversion && conversion && rm -f conversion=20


>


> Actually, it works, but I am surprised I had to build this command in


> order to apply "convert" to files in a tree. I went through the whole


> archive of this list, and the topic never surfaced. Am I missing


> something, or is directory recursion something that should be added to


> the imagemagick commands ?


>


> Explanation of the script :


> - "rm -f conversion" : erases any existing temporary file.


> - "&&" means "execute the following command if the preceding one


> finished successfully".


> - "tree -fi" : prints all the files in the directory with full path.


> - "| grep .tif" : from the output of the preceding command, filter only


> the ones containing ".tif"


> - "| awk -F. '{print "convert@@@."$2"."$3"@@@png:."$2".png"}'" : using


> the output of the preceding command, write the actual command such as


> "convert file.tif png:file.png".


> - The bunch of sed commands are there because the awk blurb actually


> does not produce the desired output and it must be massaged a bit.


> - "> conversion" dumps the resulting command lines in a temporary file.


> - "chmod 755 conversion && conversion && rm -f conversion" makes the


> temporary file executable, executes it and then deletes it.



* Previous message:

0 Comments:

Post a Comment

<< Home