Created
December 30, 2011 21:25
-
-
Save beatak/1541529 to your computer and use it in GitHub Desktop.
Convert all css files to sass files by passing directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cut="/usr/bin/cut" | |
sass_convert="/usr/bin/sass-convert" | |
if [ $# -ne 1 ];then | |
echo "USAGE: convert_css_to_sass ~/target/directory" | |
exit | |
fi | |
if [ -z "$1" ];then | |
echo "USAGE: convert_css_to_sass ~/target/directory" | |
exit | |
fi | |
first=`echo $1| $cut -c1` | |
case $first in | |
/) | |
#absolute path is passed | |
target=$1 | |
;; | |
*) | |
current=$(cd $(dirname $0); pwd) | |
target=$(cd $current/$1; pwd) | |
;; | |
esac | |
if [ ! -d $target ]; then | |
echo "$target doesn't seem to exist" | |
exit | |
fi | |
filenames=$(find ${target} -type f -name *.css) | |
for file in ${filenames[@]};do | |
filepath=${file%/*} | |
filename=${file##*/} | |
filename_noextension=${filename%.*} | |
filename_extension=${filename##*.} | |
$sass_convert -F css -T sass $file $filepath/$filename_noextension.sass | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment