USM Bish wrote:
>
> On Thu, Jun 27, 2002 at 12:02:46PM -0600, [EMAIL PROTECTED] wrote:
> >
> > It worked, but changes only ext .abc to .xyz style. Not increamental.
> >
> > Thanks Bish, but I want incremental extention. Why r u testing my weak
> > IQ ? :( Pl help !
> >
> ---end quoted text---
>
> Okay, this script should take any file with a specified extn,
> and rename it to any other with an incremental suffix with a
> specified character. Run it as: "scriptname extn char"
> [e.g. scriptname abc s] where you want extn to be s01, s02 ..
> for all files ending with .abc to be changed.
>
> -----------------<snip>-----------------
> #!/bin/bash
>
> if [ $# -ne 2 ]; then
> echo "Usage: `basename $0` old_suffix new_suffix_char"
> exit 1
> fi
>
> CNT=0
> NEW_SFX_CHAR=$2
> OLD_SFX=$1
>
> for FILENAME in *$OLD_SFX; do
> CNT=$((CNT+1))
> NEW_SFX_2=`printf "%02d" $CNT`
> NEW_SFX=$NEW_SFX_CHAR$NEW_SFX_2
> echo "moving $FILENAME to ${FILENAME%$1}$NEW_SFX"
> mv $FILENAME ${FILENAME%$1}$NEW_SFX"
> done
>
> exit 0
Thanks, Bish!
From my old reply ( I think you have missed this portion ) :
-----------------------------------------------------------
OK, but instaed of simply changing the file extention from .abc to .def , I
want .s01, .s02 ... .s12 etc. i.e. the pipe command should pick up first
letter of the file-name ( "s" in this case ) and the rest 2 chars of file
extention should have "01", "02" etc in increasing order for that particular
letter.
The extention should be exactly 3-letter word in the above format.
Any how, I have given enough trouble to all of you !
I will experiment a bit with your code, myself !
Thanks to Philip also !
Regards & thanks to all !
PS: Let me try Chandrakumar also. :)
~ Pat
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/linux-india-help