Last active
December 14, 2015 10:49
-
-
Save dettmering/5075213 to your computer and use it in GitHub Desktop.
Bash: Parse all GD files in folder
This file contains 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/bash | |
# This script creates eps files from all .gd or .exec files in a directory. | |
if [ ! -d "img/" ]; | |
then | |
mkdir img | |
fi | |
rm img/*-gd.eps | |
touch execfile # Create execfile | |
for f in *.* | |
do | |
if [ ${f#*.} = "gd" ]; | |
then | |
g=$(echo $f | sed 's/\(.*\)\..*/\1/') | |
echo "gr $g.gd" >> execfile | |
echo "gd" >> execfile | |
echo "gcopy $g-gd.eps" >> execfile | |
fi | |
if [ ${f#*.} = "exec" ]; | |
then | |
g=$(echo $f | sed 's/\(.*\)\..*/\1/') | |
echo "exec $g.exec" >> execfile | |
echo "gcopy $g-gd.eps" >> execfile | |
fi | |
done | |
echo "quit" >> execfile | |
gd < execfile # run execfile in GD | |
rm execfile # delete execfile | |
mv *.eps img/ # move generated EPS files to img directory | |
if [ -d "$HOME/Dropbox/" ]; | |
then | |
echo Copying files to Dropbox ... | |
cp img/*.eps $HOME/Dropbox/img | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment