Advertisement
akovia

Rename.sh

Aug 2nd, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.38 KB | None | 0 0
  1. #!/bin/bash
  2. set -v
  3. #trap read debug
  4. b=1
  5. space=" "
  6.  
  7. FONTFORGE_LANGUAGE=ff
  8. export PATH FONTFORGE_LANGUAGE
  9. export FONTFORGE_VERBOSE
  10.  
  11. SAVEIFS=$IFS
  12. IFS=$(echo -en "\n\b")
  13.  
  14. convert2otf2() {
  15.         set -v
  16.     #trap read debug
  17.   #tiny ff pe script to grab family name. var saved to $FAMILY
  18.   FAMILY=$(./rename_family.pe $1);
  19.   PATHNAME=$(dirname $1); #echo "PATHNAME: $PATHNAME";
  20.   FONTFILE=$(basename $1); #echo "FONTFILE: $FONTFILE";
  21.   FIRSTLTR=${FAMILY:0:1};
  22.   #make FIRSTLTR lowercase
  23.   FIRSTLOW=${FIRSTLTR,,}; #echo "FIRSTLTR: $FIRSTLTR";
  24.   FAMPATH="$PATHNAME/$FIRSTLOW/$FAMILY";
  25.   if (test -f $1); then
  26.     #multiple iif statement to check for letter directory and family directory unneeded.
  27.     #mkdir will create parents if they don't exist.
  28.     echo -n "checking existence of $FAMPATH ... ";
  29.     if [ ! -d "$FAMPATH" ]; then
  30.       echo "created new directory $FAMPATH!";
  31.       mkdir -p $FAMPATH;
  32.     else
  33.       echo "$FAMPATH exists... skipping creation.";
  34.     fi
  35.     echo -n "CALLING FONTFORGE: ";
  36.     echo "any2ttf.pe $1 $2 $FAMPATH";
  37.     #sourcing any2tff.pe - probably not necessary since it's a fontforge script and not bash; can't hurt
  38.     #source ./any2ttf.pe $1 $2 $FAMPATH;
  39.     mv -n $1 $FAMPATH;
  40.     fi
  41. }
  42.  
  43. for i in *.{otf,ttf}; do
  44.   echo "=============================================================";
  45.   convert2otf2 $i;
  46. done
  47. IFS=$(echo -en "\n\b")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement