Greetings,
I am new to scripting, but find if I can see the code working for a given problem, then I can eventually figure it out.
Greetings,
I am new to scripting, but find if I can see the code working for a given problem, then I can eventually figure it out.
Rocinante,
I wish you had put more details, such as examples of more input
and what expected output you want.
In any event, is this what you want:
typeset -i mCnt=1
typeset -Z4 mCntOut
for mInFile in DSCN*.JPG
do
mCntOut=$mCnt
mOutFile=${mInFile%'.JPG'}'_'$mCntOut'.JPG'
echo "mInFile = <"$mInFile"> mOutFile = <"$mOutFile">"
mCnt=${mCnt}+1
done
I think if I gave you the details of what I am trying to do, it would give you a bigger headache than mine;)
Thanks!
Thanks again for your help!
for s in $(seq 1 5)
do
val=$(printf "%04d" $s)
mv DSCN-${s}.JPG DSCN-${val}.JPG
done
my sincere thanks 2 u both!
I tried both of these and neither seemed to produce the desired result.
thanks anyways
roc
Try and adapt this script :
#
# Get informations from path
#
imgs_path=$1
set -- `echo $imgs_path | tr 'A-Z/' 'a-z '`
imgs_show=$2
imgs_shot=$3
imgs_element=$6
set -- `echo $7 | tr '_' ' '`
imgs_resolution=$1
imgs_colorspace=$2
#
# Rename image files
#
new_root=${igms_element}_${imgs_resolution}_${imgs_colorspace}
new_seq=0
new_ext=jpg
cd $imgs_path
ls | \
awk '
{
if (match(tolower($0), /-[0-9]+\.jpg$/)) {
print substr($0, 1, RSTART-1), \
substr($0, RSTART+1, RLENGTH-5), \
substr($0, length-2);
}
}
' | \
sort -k1,1 -k2,2n | \
while read img_root img_seq img_ext
do
img_name="${img_root}-${img_seq}.${img_ext}"
new_seq=`expr $new_seq + 1`
new_name=${new_root}.`expr "0000${new_seq}" : '^.*\(....\)$'`.${new_ext}
echo "mv ${img_name} ${new_name}"
done
Jean-Pierre.
if they don't produce the desired results, then have you tried to tweak them until you find the correct results? the concepts have been given to you. also "neither seemed to produce...." doesn't help us to help you at all...what is the output you got and what errors did you encounter if any?
i did some tweeking and it works. amazing.
btw what shell is this script?
i tested on bash shell.. i don't know how you tweaked it, but if you did not change any shells and it works for you, most probably you are using bash too. to confirm , you can use echo $SHELL to see your current shell.