Starting Point for backup script

D

Dan Vesma

Good Morning Group,

I am looking at the possibilities of creating a script that I can run
on my Mac that will scour through the directory structure and copy any
new MS Word Documents into a newly created folder on an External HDD.
I use a naming convention on my documents that does not allow two to
have the same name and it would not need to maintain a directory
structure. If I create a new document in a directory buried somewhere
in the system, I just want it copied to another directory at the end
of the day.

I'm a novice, and my Perl experience is purely on the CGI side of
things. I was hoping that you might be able to give me a bit of an
‘in' on how to start working with files. As I see it, the tasks for
the script are:

1. Create destination directory for all found files
2. Find its way around the directory structure.
3. Filter so that it only looks at Word documents
4. Check date created
5. If date created is today, copy file to destination directory and
move onto the next

It sounds so simple, but I'm sure it can't be.

Any help or advice gladly received.

Thanks,


Dan
 
M

Martin Kissner

Dan Vesma wrote :
Good Morning Group,

I am looking at the possibilities of creating a script that I can run
on my Mac that will scour through the directory structure and copy any
new MS Word Documents into a newly created folder on an External HDD.
I use a naming convention on my documents that does not allow two to
have the same name and it would not need to maintain a directory
structure. If I create a new document in a directory buried somewhere
in the system, I just want it copied to another directory at the end
of the day.

I'm a novice, and my Perl experience is purely on the CGI side of
things. I was hoping that you might be able to give me a bit of an
‘in' on how to start working with files. As I see it, the tasks for
the script are:

1. Create destination directory for all found files
2. Find its way around the directory structure.
3. Filter so that it only looks at Word documents
4. Check date created
5. If date created is today, copy file to destination directory and
move onto the next

I'm not expirienced enough in perl to know if there is an easy approach
to this in perl.
Howerver, I would realize this task as a shell script using rsync or
hfsrsync (which is not preinstalled!) or find/ditto etc. depending on
the stucture of your directory-tree.

HTH
Martin
 
W

wikka

A couple of small things.

1.Make general script and put what is to be copied in separate config file.
That cfg file could eg have list of rules/globs

2.Handle filelist as a text file more than files themselves. This will cost
less, and do the real copying at lthe latest phase.

3. Remeber to do logging so script can see what is copied earlier and what
dates and so on for those files.
 
A

A. Sinan Unur

MacOS9 or X?

I don't know. Which one do you prefer? I have heard some people still
holding on to their MacOS9 machines. Some others prefer the cool look of
the new widgets in Mac OS X. Opinions vary. Me, I have never warmed up to
Macs, ever since I found out that I had to drag the floppy icon to the
trash to be able to get it out of the drive.

When posting, please provide some context so everyone else knows what you
are talking about.

Sinan
 
S

Sherm Pendley

Dan said:
I am looking at the possibilities of creating a script that I can run
on my Mac that will scour through the directory structure and copy any
new MS Word Documents into a newly created folder on an External HDD.
....

1. Create destination directory for all found files

Easy. "perldoc -f mkdir". The user who runs your script will need to have
permission to create the directory. Don't forget to check to see if it's
already been created!
2. Find its way around the directory structure.
3. Filter so that it only looks at Word documents

Easy enough with File::Find. If you're using a recent Word and you've given
your documents extensions, you can simply use file names. If you're using
an old version of Word in Classic, and/or you're allergic to file name
extensions, you can use Mac::Carbon's GetFileInfo() function to get the
type and creator code.
4. Check date created

Don't you mean date last modified? That's normally what backups are based
on, and anyway I'm not certain if creation date is kept. Anyway - use
stat() (perldoc -f stat).
5. If date created is today, copy file to destination directory and
move onto the next

Use File::Copy. Or, if you need to preserve metadata and resource forks, run
the '/Developer/Tools/CpMac' command-line tool.
It sounds so simple, but I'm sure it can't be.

The concept is simple, but the devil is in the details, as the saying goes.

sherm--
 
L

Larry

A. Sinan Unur said:
When posting, please provide some context so everyone else knows what you
are talking about.

you're right, although you can't tell the difference between X or
Classic, no offence.
 
B

Bart Lateur

A. Sinan Unur said:
Me, I have never warmed up to
Macs, ever since I found out that I had to drag the floppy icon to the
trash to be able to get it out of the drive.

Yes, that's about the most stupid UI trick Apple ever introduced. I
never use it, my intuition tells me it might be changed to wipe the disk
some day.

I always use the cmd-Y key combination.
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top