Article View: es.comp.os.linux.programacion
Article #14975Re: �Necesito aprender Perl?
From: Han Solo
Date: Wed, 30 Aug 2000 00:00
Date: Wed, 30 Aug 2000 00:00
120 lines
4278 bytes
4278 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jos� Carlos Garc�a Sogo <jsogo@arrakis.es> writes:
> La cuesti�n es que crear una p�gina para todas las fotos con la versi�n
> reducida y un enlace a la versi�n "grande" es un poco co�azo (exceso de
> <a href...> <img src=..> </a>). Para solucionarlo he pensado en hacer un
> script que lo haga autom�ticamente, es decir, coja el nombre de las
> fotos del directorio donde est�n y vaya generando la p�gina, pero no s�
> c�mo hacerlo.
Te mando un script que hace eso exactamente. Coge un directorio, crea
la versi�n reducida, y crea autom�ticamente la p�gina o p�ginas con un
enlace. Esta escrito en bash.
Nota para los puristas: No es muy elegante, ya lo se, pero para lo que
yo necesito, funciona de pbwbarf :).
#!/bin/bash
lista=$(echo *.jpg)
elementos=$(ls *.jpg|wc -l)
limite=5
INDEX="../index.html"
INDICE="../indices/indice"
incremento=0
contador=0
numimg=0
carpeta=1
if [ $(($elementos % $limite)) -gt 0 ]; then
incremento=1
fi
total=$((($elementos / $limite) + $incremento))
echo "<html>">$INDEX
echo "<body>">>$INDEX
echo "<a href=\"../\">Directorio superior</a><p>">>$INDEX
mkdir -p ../sellos
mkdir -p ../indices
for i in $lista; do
if [ $contador -eq 0 ]; then
echo "Creando �ndice $carpeta"
numfin=$(($limite * $carpeta))
numini=$(($numfin - $limite))
echo "Numimg -->$numimg"
echo "<a href=\"indices/indice.$carpeta.html\"> Indice $carpeta</a> im�genes $numini-$(($numimg + 5))<br>">>$INDEX
echo "<html>">$INDICE.$carpeta.html
echo "<body>">>$INDICE.$carpeta.html
if [ $carpeta -gt 1 ];then
echo "<a href=\"indice.$(($carpeta - 1)).html\"><<Anterior</a>">>$INDICE.$carpeta.html
fi
echo "<a href=\"../index.html\">Arriba</a>">>$INDICE.$carpeta.html
if [ $carpeta -lt $total ];then
echo "<a href=\"indice.$(($carpeta + 1)).html\">Siguiente>></a>">>$INDICE.$carpeta.html
fi
echo "<table>">>$INDICE.$carpeta.html
fi
geometry=$(identify $i)
echo $geometry
xsize=$(echo $geometry | sed 's/'$i' \([0-9]*\)x\([0-9]*\).*/\1/g')
ysize=$(echo $geometry | sed 's/'$i' \([0-9]*\)x\([0-9]*\).*/\2/g')
echo $xsize $ysize
convert -size $(expr $xsize / 10)x$(expr $ysize / 10) $i ../sellos/S$i
echo "<tr><td><a href=\"../sellados/$i\"><img src=\"../sellos/S$i\" alt=\"\" border=0></a><td><a href=\"../sellados/$i\">$i</a>">>$INDICE.$carpeta.html
contador=$(expr $contador + 1)
numimg=$(expr $numimg + 1)
echo "num $numimg"
echo "$contador $carpeta"
if [ $contador -eq $limite ]; then
echo "</table>">>$INDICE.$carpeta.html
echo "</body>">>$INDICE.$carpeta.html
echo "</html>">>$INDICE.$carpeta.html
contador=0
carpeta=$(expr $carpeta + 1)
fi
done
echo "</table>">>$INDICE.$carpeta.html
echo "</body></html>">>$INDICE.$carpeta.html
echo "<hr><i>�ltima actualizaci�n:</i><br><pre>`date`</pre>">>$INDEX
echo "</body></html>">>$INDEX
echo $elementos
echo $total
- --
Un Saludo
Han Solo
The Rebel Alliance
Emacs is not on every system
So what? [...] Do you tell your administrative people to stick with
notepad.exe? Do you tell your fat kids they can only have the crummy
games that come with their video games or plain dress that comes with
Barbie?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.5 and Gnu Privacy Guard <http://www.gnupg.org/>
iEYEARECAAYFAjmtFsgACgkQ4FjpJaPEp22lxgCg7YIDDHPC0mKRruh/4rRpSQI2
ZyYAoPyFna/kjG/0HobTS0os5gz54mvK
=l5KN
-----END PGP SIGNATURE-----
Technical Details
Message-ID:
<87wvgyal9g.fsf@alderaan.maptel.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<39A6E9C9.9AF15685@arrakis.es>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,8d6e22777876f216 X-Google-Attributes: gidf86c8,public From: Han Solo <hsolo@maptel.es> Subject: Re: �Necesito aprender Perl? Date: 2000/08/30 Message-ID: <87wvgyal9g.fsf@alderaan.maptel.es> X-Deja-AN: 664342637 Content-Transfer-Encoding: 8bit References: <39A6E9C9.9AF15685@arrakis.es> Organization: The Rebel Alliance X-Server-Date: 30 Aug 2000 14:14:51 GMT Content-Type: text/plain; charset=iso-8859-1 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 Mime-Version: 1.0 Newsgroups: es.comp.os.linux.programacion