[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [linux-team] conversion en vrac



> for i in ` ls *.pnm|cut -d. -f1`; do convert $i.pnm 
> jpg:$i.jpg && rm $i.pnm 
> ; done
> Mis a part le cut qui ne tient pas compte de plusieurs points 
> eventuels 
> (impossible ici) et qui pourrait etre remplace par un sed, 
> voyez-vous une 
> autre facon de faire ?
> Le probleme principal ici est que "for i in *.pnm" va mettre dans $i 
> l'extension pnm et donc changer le nom en .jpg est plus 
> difficile (appeler 
> cut a chaque ligne me parait assez mauvais par rapport la 
> solution plus haut).
> Des idees ?

for i in *.pnm; do
	[ -r "$i" ] && convert -quality 80 "$i" "jpeg:${i%%.pnm}.jpg"
done

voilà ;)

Note que ça marche uniquement avec bash, pas avec ksh ou sh

--
  -o)  Pascal Bleser        | Those who  do  not  understand
  /\\  C++/UNIX Development | Unix are condemned to reinvent
 _\_v  ATOS Payment Systems | it, poorly.
       Aachen, Germany      | --Henry Spencer {fortune}
<pbleser@atos-group.com>------------------<guru@linuxbe.org> 
--------
Visit the Linux Supertore Online: http://www.redcorp.com !
If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.
Archive of the list: http://tania.be.linux.org/