Mahlzeit,
ich brauche etwas hilfe bei einem teil eines skriptums, welches dateien mit neuem namen und fortlaufender nummer versieht.
for x in `ls -1 | ${grep} -E 'bmp|tif|jpg|jpeg'`;do
extension=`echo ${x} | ${awk} -F '.' '{print $2}'`
mv ${x} ${name}_${count}.${extension}
count=`expr ${count} + 1`
done
das umbenennen fuktioniert soweit ganz gut. mich stoert jedoch, dass die fortlaufende nummer nicht von anfang an mehrstellig ist. ich haette es ganz gerne, dass die sich ergebenden namen so aussehen:
file_0001.jpg
file_0002.jpg
file_0003.jpg usw.
irgendeine idee oder anregung in welche richtung ich schauen soll?
hier noch mal das ganze skriptum.
#!/bin/sh
grep=/usr/xpg4/bin/grep
awk=/usr/local/bin/awk
convert=/usr/local/bin/convert
exif=/opt/csw/bin/exiftool
today=`/bin/date +"%Y_%m_%d_%k-%M"`
name=$1
compression=$2
count=1
thumbresize="100x100"
interresize="800x800"
archive=Archive_${today}
archivedir="/var/ftp_anonymous/pub/Photos"
exif_make="Canon"
exif_model="A1"
exif_artist="WieWaldi"
exif_copyright="WieWaldi"
exif_exposuretime="1/60"
exif_fnumber="5,6"
exif_exposureprogram="manual"
exif_iso="100"
exif_shutterspeedvalue="1/60"
exif_aperturevalue="5"
exif_exposurecompensation="0"
exif_flash="no flash"
exif_focallength="50mm"
exif_usercomment="Affe"
exif_filesource="Film Scanner"
exif_exposuremode="Manual"
if [ $# -ne 2 ]; then
echo 1>&2 "\nFucking Usage is: $0 Name N\n"
echo 1>&2 " Where Name is the new file name\n Where N is the Compression Rate.\n\n"
exit 3
fi
for x in `ls -1 | ${grep} -E 'bmp|tif|jpg|jpeg'`;do
extension=`echo ${x} | ${awk} -F '.' '{print $2}'`
mv ${x} ${name}_${count}.${extension}
count=`expr ${count} + 1`
done
mkdir ${archivedir}/${archive}
for X in `ls -1 | ${grep} -E 'bmp|tif|jpg|jpeg'`;do
Y=`echo $X | awk -F '.' '{print $1}'`
YA=`echo ${Y}_thumb.jpg`
YB=`echo ${Y}_intermediate.jpg`
YC=`echo ${Y}_origsize.jpg`
echo "Resizing $X Image to Thumbnail $YA"
${convert} ${X} -resize ${thumbresize} -quality ${compression} ${archivedir}/${archive}/${YA}
echo "Resizing $X Image to Intermediate $YB"
${convert} ${X} -resize ${interresize} -quality ${compression} ${archivedir}/${archive}/${YB}
${exif} -overwrite_original \
-make=${exif_make} -model=${exife_model} -artist=${exif_artist} -copyright=${exif_copyright} \
-exposuretime=${exif_exposuretime} -fnumber=${exif_fnumber} \
-exposureprogram=${exif_exposureprogram} -iso=${exif_iso} -shutterspeedvalue=${exif_shutterspeedvalue} \
-aperturevalue=${exif_aperturevalue} -exposurecompensation=${exif_exposurecompensation} \
-flash="${exif_flash}" -focallength=${exif_focallength} -usercomment=${exif_usercomment} \
-filesource="${exif_filesource}" -exposuremode=${exif_exposuremode} ${archivedir}/${archive}/${YB}
echo "Converting ${X} Image to JPEG ${YC}, whith a rate of $1"
${convert} ${X} -quality ${compression} ${archivedir}/${archive}/${YC}
${exif} -overwrite_original \
-make=${exif_make} -model=${exife_model} -artist=${exif_artist} -copyright=${exif_copyright} \
-exposuretime=${exif_exposuretime} -fnumber=${exif_fnumber} \
-exposureprogram=${exif_exposureprogram} -iso=${exif_iso} -shutterspeedvalue=${exif_shutterspeedvalue} \
-aperturevalue=${exif_aperturevalue} -exposurecompensation=${exif_exposurecompensation} \
-flash="${exif_flash}" -focallength=${exif_focallength} -usercomment=${exif_usercomment} \
-filesource="${exif_filesource}" -exposuremode=${exif_exposuremode} ${archivedir}/${archive}/${YC}
done
exit 0