• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

Gelöst: Skript für alle pdf Dateien im Verzeichnis ausführen

Heart

Hacker
Hallo,

ich habe ein Skript, dass mir aktuell eine bestimmte Datei namens tabelle.pdf mittels imagemagick bearbeitet und eine tabelle.png daraus macht.

Wie müsste ich das abändern, das es eben nicht nur mit der einen Datei tabelle.pdf funktioniert, sondern mit allen *.pdf Dateien, die im selbigen Verzeichnis liegen.

Also
tabelleA.pdf sollte dann eine tabelleA.png generieren,
tabelleB.pdf sollte dann eine tabelleB.png generieren,
usw.

Vielen Dank!

Code:
convert -density 300 tabelle.pdf -background white -flatten tabelle.png

convert \
  tabelle.png \
  -chop 0x638+0+0 \
  -chop 360x0+2120+0 \
  -chop 200x0+1520+0 \
  tabelle.png

convert tabelle.png -crop 1870x1300+50+20 -trim +repage tabelle.png

convert tabelle.png -size ${width}x60 xc:white -append tabelle.png

convert \
        tabelle.png \
        -chop 110x0+600+0 \
        -chop 40x0+730+0 \
        -chop 110x0+800+0 \
        -chop 110x0+900+0 \
        -chop 90x0+1000+0 \
        -chop 40x0+1210+0 \
        tabelle.png

convert \
        tabelle.png \
        -pointsize 24 \
        -fill white \
        -undercolor black \
        -gravity SouthEast \
        -annotate +10+10 " Stand: $(date +%e.\ %b\ %Y\ %H:%M) " \
        tabelle.png

exit 0
 

abgdf

Guru
Code:
ls *pdf | while read i
do
    a=$(echo $i | awk -F ".pdf" '{print $1}')
    a="$a.png"
    convert -density 300 $i -background white -flatten $a

    convert \
      $a \
      -chop 0x638+0+0 \
      -chop 360x0+2120+0 \
      -chop 200x0+1520+0 \
      $a

    convert $a -crop 1870x1300+50+20 -trim +repage $a

    convert $a -size ${width}x60 xc:white -append $a

    convert \
            $a \
            -chop 110x0+600+0 \
            -chop 40x0+730+0 \
            -chop 110x0+800+0 \
            -chop 110x0+900+0 \
            -chop 90x0+1000+0 \
            -chop 40x0+1210+0 \
            $a

    convert \
            $a \
            -pointsize 24 \
            -fill white \
            -undercolor black \
            -gravity SouthEast \
            -annotate +10+10 " Stand: $(date +%e.\ %b\ %Y\ %H:%M) " \
            $a
done

exit 0
@robi u.a.: Ich gebe zu, hier überzeugt awk. :)
 
Oben