Skip to content

Instantly share code, notes, and snippets.

@dettmering dettmering/gist:5075213
Last active Dec 14, 2015

Embed
What would you like to do?
Bash: Parse all GD files in folder
#!/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
You can’t perform that action at this time.