Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Nicht gentoo spezifisch - bash script ändern
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German)
View previous topic :: View next topic  
Author Message
SvenFischer
Veteran
Veteran


Joined: 05 Feb 2003
Posts: 1033
Location: Berlin

PostPosted: Thu Mar 07, 2013 11:00 pm    Post subject: Nicht gentoo spezifisch - bash script ändern Reply with quote

Hallo,

wer würde mir bitte helfen - dieses Skript ändert Bilder und zickt manchmal rum:

1. Er meckert, wenn er nicht die Endungen findet - das ist noch zu verschmerzen
2. Mit Leerstellen kann das Script nicht umgehen und das nervt sehr.

Code:

rray='*.jpg *.JPG *.JPEG *.jpeg *.PNG *.png'

for f in $array;
do
    echo "Processing $f"
   ww=`convert $f -format "%[fx:.25*w]" info:`
   hh=`convert $f -format "%[fx:.25*h]" info:`
   composite -gravity southeast \( /home/sven/Documents/Aquarium/Logo_Korallen-Wiki.png -resize ${ww}x${hh} \) $f $f
        convert $f -quality 90% -resize 1024x768\>  $f
done


Vielen Dank

Sven
_________________
Core2Duo, 4GB RAM, AMD/ATI 4850 and nice person in front!
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Fri Mar 08, 2013 4:37 pm    Post subject: Reply with quote

2. Überall quoten: "$f" statt "$f". Auch Argument nach -resize quoten.
1. Am Schleifenanfang testen, ob "$f" existiert: test -r "$f" || continue
Back to top
View user's profile Send private message
mastacloak
Apprentice
Apprentice


Joined: 01 Aug 2004
Posts: 174
Location: Berlin / Germany

PostPosted: Sat Mar 09, 2013 5:37 pm    Post subject: Reply with quote

Wenn Dir POSIX-Konformität nicht ganz so wichtig ist und Du bash >= v2 verwendest, kannst Du um 1. zu unterbinden auch
Code:
shopt -s nullglob

vor der Schleife in Deinem Shellscript aufrufen. Dann werden alle Pattern die zu keinem Ergebnis führen kurzerhand entfernt.
Back to top
View user's profile Send private message
SvenFischer
Veteran
Veteran


Joined: 05 Feb 2003
Posts: 1033
Location: Berlin

PostPosted: Mon Mar 11, 2013 12:01 pm    Post subject: Reply with quote

Hallo,

erstmal danke. Das mit den Leerzeichen funktioniert und ist eine enorme Hilfe!

Was nicht funktioniert ist das Abfangen der Fehlermeldungen:

Quote:

./sven: Zeile 12: Syntaxfehler beim unerwarteten Wort `test'
./sven: Zeile 12: `test -r "$f" || continue'


Das Script sieht dann so aus:
Code:

array='*.jpg *.JPG *.JPEG *.jpeg *.PNG *.png'

for f in $array;
test -r "$f" || continue
do
    echo "Processing $f"
   ww=`convert "$f" -format "%[fx:.25*w]" info:`
   hh=`convert "$f" -format "%[fx:.25*h]" info:`
   composite -gravity southeast \( /home/sven/Documents/Aquarium/Logo_Korallen-Wiki.png -resize ${ww}x${hh} \) "$f" "$f"
        convert "$f" -quality 90% -resize 1024x768\>  "$f"
done

_________________
Core2Duo, 4GB RAM, AMD/ATI 4850 and nice person in front!
Back to top
View user's profile Send private message
py-ro
Veteran
Veteran


Joined: 24 Sep 2002
Posts: 1734
Location: Velbert

PostPosted: Mon Mar 11, 2013 12:14 pm    Post subject: Reply with quote

Die test Zeile gehört nach dem do.
Back to top
View user's profile Send private message
SvenFischer
Veteran
Veteran


Joined: 05 Feb 2003
Posts: 1033
Location: Berlin

PostPosted: Mon Mar 11, 2013 11:46 pm    Post subject: Reply with quote

Vielen Dank für Eure Hilfe!
_________________
Core2Duo, 4GB RAM, AMD/ATI 4850 and nice person in front!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum