CopyFile - new files only

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
pauljohn
Newbie
Posts: 6
Joined: Mon Feb 22, 2010 3:19 pm
Location: Columbus, OH, USA
Contact:

CopyFile - new files only

Post by pauljohn » Mon Feb 22, 2010 3:50 pm

1st - I love this program!

2nd - the question
I have 2 directories, 1 local & 1 on a server.
Every day the local dir has 4 or so new files added to it.
Those need to be copied to the server.
I have a script running the program to pull the new info already.
The program pulling the new data looks at the old data 1st to see what it needs to download.
So I can't just delete everything first or I get 40 files. 36 of them I already have.
I've tried just using the server directory and not storing local, but it runs to slow.
I just want the new files copied to the server and I can schedule that for 3am when no one is at the office.
Right now I just do CopyFile and set it to Overwrite.
That will just get slower and slower as the year progresses.

Let>CF_OVERWRITE=1
CopyFile>C:\Users\me\Desktop\store\4\*.*,q:\store\004\
CopyFile>C:\Users\me\Desktop\store\38\*.*,q:\store\038\
CopyFile>C:\Users\me\Desktop\store\73\*.*,q:\store\073\
CopyFile>C:\Users\me\Desktop\store\79\*.*,q:\store\079\
... there are 40 folders in total

Not sure if this will be useful or not...
This is an example of the file names in the folders:
2010-01-20.407.1.xml.gz, 2010-01-20.407.2.xml.gz
2 files for each date plus current.1.xml.gz and current.2.xml.gz

I've search the forums for anything similar and haven't found it yet.
Thank you,
PJ

User avatar
JRL
Automation Wizard
Posts: 3518
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Feb 22, 2010 4:22 pm

You could use DOS xcopy. Open a command prompt and type in "xcopy /?" to see xcopy help. Something like this might work

Code: Select all

//Get today's date information
GetDate>date
//DOS wants the separater to be a hyphen
StringReplace>date,/,-,date

Let>rp_wait=1
Let>rp_windowmode=0
Run>cmd /c xcopy c:\test\*.* c:\tester\ /c /y /d:%date%
If you want yesterday's date add one line.

Code: Select all

//Get today's date information
GetDate>date
//use the Sub> function to go back one day
Sub>date,1
//DOS wants the separater to be a hyphen
StringReplace>date,/,-,date

Let>rp_wait=1
Let>rp_windowmode=0
Run>cmd /c xcopy c:\test\*.* c:\tester\ /c /y /d:%date%

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 22, 2010 4:22 pm

Hi,

Some possible options:

1. You could use a File Event Trigger (Macro Properties - Trigger)

2. Instead of copying with wildcards use a GetFileList to get a list of files in the folder. Loop through each one and do an IfFileExists on the destination. If it exists, don't copy, only copy if it does not exist.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

pauljohn
Newbie
Posts: 6
Joined: Mon Feb 22, 2010 3:19 pm
Location: Columbus, OH, USA
Contact:

Thank you

Post by pauljohn » Mon Feb 22, 2010 5:47 pm

I never even thought about a batch file. LOL

I think I'll try the GetFileList and see what I can do.
I may be back again

Thank you
PJ

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts