ilnanny75

inkscape converter

Apr 13th, 2019
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. count=0
  3. validInput1="svg"
  4. validInput2="pdf"
  5. validInput3="eps"
  6. validOutput1="eps"
  7. validOutput2="pdf"
  8. validOutput3="png"
  9.  
  10. echo "This script allows you to convert all files in this folder from one file type to another."
  11.  
  12. valid=0
  13. echo "Allowed file types for source: $validInput1, $validInput2, $validInput3"
  14. while [ "$valid" != "1" ]
  15. do
  16.     read -p "What file type do you want to use as a source? " sourceType
  17.     if [ "$sourceType" = "$validInput1" ] || [ "$sourceType" = "$validInput2" ] || [ "$sourceType" = "$validInput3" ]; then
  18.         valid=1
  19.     else
  20.         echo "Invalid input! Please use one of the following: $validInput1, $validInput2, $validInput3"
  21.     fi
  22. done
  23.  
  24. valid=0
  25. echo "Allowed file types for output: $validOutput1, $validOutput2, $validOutput3"
  26. while [ "$valid" != "1" ]
  27. do
  28.     read -p "What file type do you want to convert to? " outputType
  29.     if [ "$outputType" = "$validOutput1" ] || [ "$outputType" = "$validOutput2" ] || [ "$outputType" = "$validOutput3" ]; then
  30.         valid=1
  31.     else
  32.         echo "Invalid input! Please use one of the following: $validOutput1, $validOutput2, $validOutput3"
  33.     fi
  34. done
  35.  
  36. read -p "With what dpi should it be exported (e.g. 300)? " dpi
  37.  
  38. for fileSource in *.$sourceType
  39. do
  40.     if [ -f "$fileSource" ]; then    
  41.         count=$((count+1))
  42.         file=$(echo $fileSource | cut -d'.' -f1)
  43.         echo $count". "$fileSource" -> "$file.$outputType
  44.         inkscape $fileSource --export-$outputType=$file.$outputType --export-dpi=$dpi
  45.     else
  46.         echo "no file $fileSource found!"
  47.     fi
  48. done
  49. echo "$count file(s) converted!"
RAW Paste Data