Newbie Help

T

Tony heagren

Hi all...

slightly new to this, need to accomplish something simple.

I have 12 jpgs in a directory called "copy"
I need a script to rename "news1.jpg" to "news2.jpg"
and so on through the list.
So 1 becomes 2, 2 becmes 3, 3 becomes 4 etc...

The path from perl script to jpgs is simply:
.../copy/news1.jpg

All and any help much appreciated.
Tony
 
A

Anno Siegel

Tony heagren said:
Hi all...

slightly new to this, need to accomplish something simple.

I have 12 jpgs in a directory called "copy"
I need a script to rename "news1.jpg" to "news2.jpg"
and so on through the list.
So 1 becomes 2, 2 becmes 3, 3 becomes 4 etc...

The path from perl script to jpgs is simply:
../copy/news1.jpg

perldoc -f opendir
perldoc -f readdir
s/(\d+)/$1 +1/e;
perldoc -f rename

That should give you a start.

Anno
 
I

Ian Wilson

Anno said:
perldoc -f opendir
perldoc -f readdir
s/(\d+)/$1 +1/e;
perldoc -f rename

Mightn't you also need
perldoc -f sort
So that you rename foo3 to foo4 before renaming foo2 to foo3?
 
J

John Bokma

Tony heagren said:
Hi all...

Hi: pick your subject with more care.
I have 12 jpgs in a directory called "copy"
I need a script to rename "news1.jpg" to "news2.jpg"
and so on through the list.

I would fire up my editor, open a dos box, get the list of file names,
paste them in the editor, record a macro, and let that one do the trick.
 
A

Anno Siegel

Ian Wilson said:
Mightn't you also need
perldoc -f sort
So that you rename foo3 to foo4 before renaming foo2 to foo3?

You could move them to another directory at the same time.

The list isn't complete. "perldoc -f -f" would be another candidate,
to eliminate not-plain files. I wanted to give the OP enough material
to come up with an attempt at a solution. Then we could discuss that.

Anno
 
T

Tony heagren

Hi: pick your subject with more care.


I would fire up my editor, open a dos box, get the list of file names,
paste them in the editor, record a macro, and let that one do the trick.

Thanks for all your help.
In the end (owing to time pressure) I did it in Flash
and let a simple .txt file cope with being rewritten to hold
the variable names then pump them back into flash with new
instance names.

I know this would hae been quicker in perl though...
Must read the books...

Best wishes
Tony
 
J

John Bokma

Tony heagren said:
On 2005-06-23 11:56:35 +0100, John Bokma <[email protected]> said:

[ renaming 12 files ]
Thanks for all your help.
In the end (owing to time pressure) I did it in Flash

Amazing, in the editor I use (TextPad) I could do this in probably 2
minutes [1] for 12 files.

[1] While reading Usenet :-D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,244
Latest member
cryptotaxsoftware12

Latest Threads

Top