RE: bulk rename pod1 > pod2 needed

Top Page
Attachments:
Message as email
+ (text/plain)
+ (text/html)
+ (text/plain)
Delete this message
Reply to this message
Author: Lisa Kachold
Date:  
To: plug-discuss, dennisk
Subject: RE: bulk rename pod1 > pod2 needed

This will increment the second field in the file for each file in the directory named *.ext.

The last digit before dot will increment by 1; yet if it is 9 it should become 0.

[Caveat - untested...(use carefully)]:

ls *.ext |
awk -F"." '{s=substr($2,length($2))
s++;s=s==10?0:s
printf("mv %s %s%s.%s\n", $0, substr($2,1,length($2)-1), s, $3)}
' | sh


obnosis.com | wiki.obnosis.com| (503)754-4452
PLUG HACKFESTS 2nd Saturday Each Month@Noon - 3PM

Date: Mon, 16 Feb 2009 17:36:58 -0700
Subject: Re: bulk rename pod1 > pod2 needed
From:
To: ;

assuming you're just trimming off ccna, pc1, and ext

for i in $( ls )
do
mv $i $( echo $i | awk -F. '{ print $3 }' )
done

That would move them to pod# names.


On Mon, Feb 16, 2009 at 5:33 PM, Dennis Kibbe <> wrote:

Can someone suggest a way to rename a directory of files like this:



ccna.pod1.pc1.ext is renamed to ccna.pod2.pc1.ext

ccna.pod2.pc1.ext is renamed to ccna.pod3.pc1.ext



and so on.



(Aside: Hans, if I were able to take your scripting class I won't be asking this now. :-)



Dennisk



--

"Free as in Freedom"

Free Software Foundation

---------------------------------------------------

PLUG-discuss mailing list -

To subscribe, unsubscribe, or to change your mail settings:

http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss



--
James McPhee


_________________________________________________________________
Want to do more with Windows Live? Learn “10 hidden secrets” from Jamie.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss