l=1
for FILE in *.gif
do if test $l -ge 100
then mv $FILE $l.gif
elif test $l -ge 10
then mv $FILE 0$l.gif
else mv $FILE 00$l.gif
fi
l=$((l+1))
done
A standard loop can be programmed via
for (( n=1 ; n<9 ; n=$((n+1)) )); do echo $n; done
l=1
for FILE in *.gif
do if test $l -ge 100
then mv $FILE $l.gif
elif test $l -ge 10
then mv $FILE 0$l.gif
else mv $FILE 00$l.gif
fi
l=$((l+1))
done
for (( n=1 ; n<9 ; n=$((n+1)) )); do echo $n; done
1 comment:
These comments only work in Bourne shells, i.e. either bash or zsh. Many PhD students tend to use tcsh or csh (you can check this by "echo $SHELL" on the command line). Bash and zsh are much easier to use when you want to automate repetitive and tedious tasks: contact BCF how the can help you switch.
Post a Comment