PDA

Visualizza la versione completa : script ps2pdf


Caleb
15-07-2006, 23:11
devo convertire una marea di file postscript in pdf, ma ps2pdf funziona solo so un file per volta... qualcuno in grado di modificare questo script per far s che converta tutti i file .ps di una directory?



#!/bin/sh
# $Id: ps2pdfwr,v 1.9 2002/02/21 21:49:28 giles Exp $
# Convert PostScript to PDF without specifying CompatibilityLevel.

OPTIONS="-dSAFER"
while true
do
case "$1" in
-?*) OPTIONS="$OPTIONS $1" ;;
*) break ;;
esac
shift
done

if [ $# -lt 1 -o $# -gt 2 ]; then
echo "Usage: `basename $0` [options...] (input.[e]ps|-) [output.pdf|-]" 1>&2
exit 1
fi

infile="$1";

if [ $# -eq 1 ]
then
case "${infile}" in
-) outfile=- ;;
*.eps) base=`basename "${infile}" .eps`; outfile="${base}.pdf" ;;
*.ps) base=`basename "${infile}" .ps`; outfile="${base}.pdf" ;;
*) base=`basename "${infile}"`; outfile="${base}.pdf" ;;
esac
else
outfile="$2"
fi

# We have to include the options twice because -I only takes effect if it
# appears before other options.
exec gs $OPTIONS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=$outfile" $OPTIONS -c .setpdfwrite -f "$infile"

cacao74
15-07-2006, 23:44
All'occorrenza, io faccio qualcosa del genere:


cacao74@mediacenter:~$ pwd
/home/cacao74

cacao74@mediacenter:~$ ls ps
file1.ps file2.ps file3.ps

cacao74@mediacenter:~$ cd pdf

cacao74@mediacenter:~/pdf$ pwd
/home/cacao74/pdf

cacao74@mediacenter:~/pdf$ for file in /home/cacao74/ps/*.ps; do ps2pdf $file; done

cacao74@mediacenter:~/pdf$ ls -l
totale 288
-rw-r--r-- 1 cacao74 cacao74 90264 2006-07-15 22:41 file1.pdf
-rw-r--r-- 1 cacao74 cacao74 90264 2006-07-15 22:41 file2.pdf
-rw-r--r-- 1 cacao74 cacao74 90264 2006-07-15 22:41 file3.pdf

ciao

Caleb
15-07-2006, 23:49
uh, e mica ci avevo pensato di ciclare lo script stesso invece di modificarlo... gracias

Loading