So here's my soution to the problem. This will rename .002 onwards to .r00, leaving you to rename .001 to .rar. I could have added that but couldn't be arsed as it's a two second job to do a manual rename on a single file. 46 other files would have taken quite a bit longer.
#!/bin/shfor i in `ls -a *.0*`doEXTENSION="$(echo ${i#*.})"FNAME="$(echo ${i%.*})"NEWNUM="$(echo $EXTENSION |sed 's/^0*//')"NEWNUM="$(($NEWNUM -2))"FINAME=""if [ "$NEWNUM" -lt "10" ]; thenFINAME="$(echo $FINAME)0";fiFINAME="$(echo $FINAME$NEWNUM)"FINAME="$(echo ${FNAME}.r$FINAME)"echo "${i} -> ${FINAME}"mv "$i" "$FINAME"done
Probably not the most efficient script, but it works so there :)
No comments:
Post a Comment