incrementing file names

L

Lars Tackmann

Hi.

I am creating a perl script that will rename a file called
SEGEyyyyyyy.dat (yyyyyyy is a number) to Oxxxxxddmm (where xxxxx is a
number that is incremented by one for each file and ddmm is the day and
the month).

My problem is now that the files are send via ftp and deleted from this
machine (where the scipt has to run). So I need some way to keep track
on my xxxxx numbers - without searing the file names on the disk -

Thanks.
 
R

Ragnar Hafstað

Lars Tackmann said:
I am creating a perl script that will rename a file called
SEGEyyyyyyy.dat (yyyyyyy is a number) to Oxxxxxddmm (where xxxxx is a
number that is incremented by one for each file and ddmm is the day and
the month).

My problem is now that the files are send via ftp and deleted from this
machine (where the scipt has to run). So I need some way to keep track
on my xxxxx numbers - without searing the file names on the disk -

whats wrong with keeping your current xxxxx in a data file along with the
script?

gnari
 
J

Jim Keenan

Lars Tackmann said:
Hi.

I am creating a perl script that will rename a file called
SEGEyyyyyyy.dat (yyyyyyy is a number) to Oxxxxxddmm (where xxxxx is a
number that is incremented by one for each file and ddmm is the day and
the month).

My problem is now that the files are send via ftp and deleted from this
machine (where the scipt has to run). So I need some way to keep track
on my xxxxx numbers - without searing the file names on the disk -
You will almost certainly have to store _something_ on disk; otherwise you
would have to go to the ftp site to see what the next number to be assigned
is.

But what you store could be as simple as a file containing a hash keyed by
'mmdd' (or, for greater flexibility, 'yyyymmdd') which increments a counter
for each key:
file: date.config
%dateconfig = (
20031226 => 00005,
20031227 => 00003,
...
)

.... in your main package:
our (%dateconfig);
require date.config;

Then increment the number and date and format accordingly with 'sprintf'.

Jim Keenan
 
J

James Willmore

I am creating a perl script that will rename a file called
SEGEyyyyyyy.dat (yyyyyyy is a number) to Oxxxxxddmm (where xxxxx is
a number that is incremented by one for each file and ddmm is the
day and the month).

My problem is now that the files are send via ftp and deleted from
this machine (where the scipt has to run). So I need some way to
keep track on my xxxxx numbers - without searing the file names on
the disk -

What have you written so far? I have several guesses as to what you
want to do, but code would be helpful.

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
There is nothing wrong with Southern California that a rise in
the ocean level wouldn't cure. -- Ross MacDonald
 

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
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top