Advertisement
saper_2

Batch search and convert SVG files to PNG using rsvg-convert

Sep 17th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.09 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # temporary file
  4. TMP=tmp.txt
  5. # size (width) of output png file (aspect-ratio is kept)
  6. WSIZE=16
  7. # destination direcotry where to move generated PNGs
  8. DEST=./pngs16
  9.  
  10. echo "*********** STARTING CONVERSION **********"
  11. echo -n "Searching files... "
  12. find . -iname "*.svg" > $TMP
  13.  
  14. num=$(wc -l < "$TMP")
  15. echo "$num .svg files found."
  16. # test line=./specific_applications/sonata/sonata_play.svg
  17.  
  18.  
  19. echo -n "Converting files"
  20.  
  21. while read line
  22. do
  23.         rsvg-convert -w $WSIZE -a -f png -o ${line%.svg}[w$WSIZE].png $line
  24.         echo -n "."
  25. done <$TMP
  26.  
  27. echo " "
  28. #echo "Press enter to continue..."
  29. #read
  30.  
  31. echo " "
  32. echo -n "Searching converted png files..."
  33.  
  34. find . -iname "*\[w$WSIZE\].png" > $TMP
  35.  
  36. num2=$(wc -l < "$TMP")
  37. echo "$num2 files found."
  38.  
  39. echo "Moving files to directory: $DEST"
  40. while read line
  41. do
  42.         line2=${line//\//_}
  43. #       echo "- file '${line}' to '$DEST/${line2#._}' "
  44.         mv ${line} $DEST/${line2#._}
  45.         echo -n "."
  46. done <$TMP
  47.  
  48. echo " "
  49. echo " "
  50. echo "Removing temporary files."
  51. rm $TMP
  52. echo "***************** DONE *******************"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement