Skip to content

Instantly share code, notes, and snippets.

@dettmering
Last active December 14, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dettmering/5075213 to your computer and use it in GitHub Desktop.
Save dettmering/5075213 to your computer and use it in GitHub Desktop.
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