RE: bulk rename pod1 > pod2 needed

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Bob Elzer
Date:  
To: 'Main PLUG discussion list'
Subject: RE: bulk rename pod1 > pod2 needed
What hasn't been answered is if this is open ended ?

Are you going to keep counting forever, thus keeping on to 25, 26, 27.....

Or can we cut it off at a particular number ? 24 ?

If we can cut it off then this simple solution would work

cd /the_directory
mv ccna.pod23.pc1.ext to ccna.pod24.pc1.ext
mv ccna.pod22.pc1.ext to ccna.pod23.pc1.ext
mv ccna.pod21.pc1.ext to ccna.pod22.pc1.ext
.
.
mv ccna.pod1.pc1.ext to ccna.pod2.pc1.ext
touch ccna.pod1.pcl.ext

If these are log files of some kind, you may want to look at the command
"logrotate" which is designed for such things.

Your initial message just asks how to rename the files, but in order to come
up with the correct solution you need to explain more on what you are trying
to accomplish.

Otherwise you get lots of different answers, all very valid, but
accomplishing different things.

For instance, if you move 1 to 2, then 2 to 3, and 3 to 4. You end up with 1
file that was originally 1, and could have been done 1 to 4.

Even after we know what you are trying to accomplish, the great thing is in
linux there are many ways to do it.



-----Original Message-----
From:
[mailto:plug-discuss-bounces@lists.plug.phoenix.az.us] On Behalf Of Alex
Dean
Sent: Tuesday, February 17, 2009 12:47 PM
To: Main PLUG discussion list
Subject: Re: bulk rename pod1 > pod2 needed


On Feb 17, 2009, at 11:38 AM, Dennis Kibbe wrote:

>> Actually, if the original specification is co= rrect, probably none
>> of the solutions proposed is likely to work.  It = appears that
>> the target name for the first rename is the same as the source= for
>> the second.  If this were true one would have to ensure that
>> rena= me or move operations were done in an order to avoid attempts
>> to overwrite = existing names.
>
> That's correct. So renaming needs to start at the end. (There are
> actually 24 files in the directory.)
>
> so renaming:
>
> ccna.pod24.pc1.ext to ccna.pod25.pc1.ext
>
> needs to happen before renaming:
>
> ccna.pod23.pc1.ext to ccna.pod24.pc1.ext
>
> and so on down to:
>
> ccna.pod1.pc1.ext to ccna.pod2.pc1.ext


Could you perhaps keep the original files in some other naming convention,
and create symlinks in the ccna.podXX.pc1.ext format? It might be easier to
write a script, then, to :
- remove all old symlinks
- sort the original files by descending mtime
- create new symlinks sequentially, 1-24.

This eliminates the need to parse the existing file names to figure out
which sequence number they have.

Just a thought.

alex

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss