Copy File With Time Changes

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
putmann
Junior Coder
Posts: 24
Joined: Mon Aug 20, 2007 1:15 am
Location: Queens,NY

Copy File With Time Changes

Post by putmann » Tue Apr 22, 2008 3:59 pm

This daily file, LIJ_IP_DAILY_AR_PROCESSED_04222008_052002.TXT needs to be copied to a daily file called CashLIJIP.TXT. I tried to copy it in MS, but can't do it.

LIJ_IP_DAILY_AR_PROCESSED_04222008_052002.TXT
Date Hr/Min/Sec

Any advice?

Thanks

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

Post by Marcus Tettmar » Tue Apr 22, 2008 4:01 pm

Like this:

Code: Select all

Year>yy
Day>dd
Month>mm
Hour>hh
Min>nn
Sec>ss

Let>source=c:\bla\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yy%_%hh%%nn%%ss%.TXT
CopyFile>source,c:\bla\CashLIJIP.TXT
You'll need to add in the correct paths
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

putmann
Junior Coder
Posts: 24
Joined: Mon Aug 20, 2007 1:15 am
Location: Queens,NY

Post by putmann » Wed Apr 23, 2008 2:32 pm

Thanks for the reply. MS still didn't read the file because 052002 is not the current time;this is the time that the file was created. It seems that MS is looking at %hh%%nn%%ss% as the current time. Any further advice?

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

Post by Marcus Tettmar » Wed Apr 23, 2008 2:43 pm

I'm sorry, I thought that was what you wanted - the current time.

If you want to get the file time and date use FileDate and FileTime and parse the result. But, I'm not sure how you can guarantee that the file date and file time match the date/time in the filename. They're not necessarily the same thing.

Perhaps you need to back up a bit and describe your requirements so that we can understand what you are wanting to achieve.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

putmann
Junior Coder
Posts: 24
Joined: Mon Aug 20, 2007 1:15 am
Location: Queens,NY

Post by putmann » Wed Apr 23, 2008 3:21 pm

I am using MS Version 7.4.009. I can't find Filetime in the Command Reference.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Apr 23, 2008 11:29 pm

FileTime was added in Version 9.0, 11/10/2006
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

putmann
Junior Coder
Posts: 24
Joined: Mon Aug 20, 2007 1:15 am
Location: Queens,NY

Post by putmann » Sun Apr 27, 2008 3:16 pm

I'm sorry if wasn't clear. The daily file,LIJ_IP_DAILY_AR_PROCESSED_04272008_052002.TXT needs to be copied to the file,CashLIJIP.TXT on a daily basis. The 04272008 represents today's date and the 052002 represents the time the file was created (5 AM,20 minutes and 02 seconds).

I am able to read the date, but how do I parse out the time. I tried using filetime, but was not successful. Also tried repeat/until loops.

Hope this explains it.[/quote]

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

Post by Marcus Tettmar » Sun Apr 27, 2008 3:56 pm

Let's see if we can make this simpler. I wonder if the time in the filename really matters. Are you not actually just wanting to copy the latest file in the folder each day? Or copy the latest file in the folder where the filename contains today's date? Wouldn't that do the same thing? Or even just any file with today's date e.g:

Is it ok to, once every hour, copy the following:

LIJ_IP_DAILY_AR_PROCESSED_MMDDYYYY_*.TXT

Where MMDDYYYY is today's date ...

Or we can find the latest file in the folder and check to see that it contains today's date in the filename. Would that work?

The macro could even be scheduled to take place whenever there's a new file in that folder. The macro then just copies the latest file matching the above spec.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Apr 27, 2008 4:06 pm

Is there only one file per day? If so the challenge is finding the time in the name of that file, something like this:

Code: Select all

Year>yy
Day>dd
Month>mm
//check if there is only 1 matching file otherwise abort
CountFiles>c:\Temp\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yy%*.TXT,lijcount,0
MDL>lijcount
If>lijcount=1,dothis,theend
Label>dothis
//get the full name of today's file
GetFileList>c:\temp\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yy%_*.TXT,fname,;
MDL>fname
//parse filename to get time
Separate>fname,_,fparts
MDL>fparts_7
Let>source=c:\temp\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yy%_%fparts_7%
MDL>source
CopyFile>source,c:\temp\CashLIJIP.TXT
Label>theend



putmann
Junior Coder
Posts: 24
Joined: Mon Aug 20, 2007 1:15 am
Location: Queens,NY

Post by putmann » Sun Apr 27, 2008 4:53 pm

Code: Select all

Year>yyyy
Day>dd
Month>mm

REM Inpatient file
copyfile>U:\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yyyy%_*.TXT,U:\CashLIJIP.TXT
I tried this but it didn't work

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

Post by Marcus Tettmar » Mon Apr 28, 2008 8:47 am

Try:

Code: Select all

Year>yyyy
Day>dd
Month>mm

Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run>cmd.exe /c copy "U:\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yyyy%_*.TXT" "U:\CashLIJIP.TXT"
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

putmann
Junior Coder
Posts: 24
Joined: Mon Aug 20, 2007 1:15 am
Location: Queens,NY

Post by putmann » Mon Apr 28, 2008 12:50 pm

Thanks for your help. Perfect.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Mon Apr 28, 2008 1:34 pm

Be aware that if, for whatever reason, there are multiple files matching the U:\LIJ_IP_DAILY_AR_PROCESSED_%mm%%dd%%yyyy%_*.TXT filespec they will all be combined into the destination file.

If this script is processing AR I suggest adding some error checking.

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