Skip to content

Instantly share code, notes, and snippets.

@terrbear
Created March 29, 2010 13:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save terrbear/347837 to your computer and use it in GitHub Desktop.
Save terrbear/347837 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ]; then
wdir="."
else
wdir=$1
fi
for f in $( find . -name '*.erb' ); do
out="${f%.erb}.haml"
if [ -e $out ]; then
echo "skipping $out; already exists"
rm $f
else
echo "hamlifying $f"
html2haml $f > $out
rm $f
fi
done
@carlthuringer
Copy link

With rm, plus it didn't work for me so I changed ls to find.

#!/bin/bash
if [ -z "$1" ]; then
  wdir="."
else
  wdir=$1
fi

for f in $( find . -name '*.erb' ); do
  out="${f%.erb}.haml"
  if [ -e $out ]; then
    echo "skipping $out; already exists"
    rm $f
  else
    echo "hamlifying $f"
    html2haml $f > $out
    rm $f
  fi
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment