Copyfile and Movefile don't work

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
LE1202
Newbie
Posts: 6
Joined: Tue Feb 21, 2017 12:55 pm

Copyfile and Movefile don't work

Post by LE1202 » Sun Mar 12, 2017 12:08 am

Hi, I posted question few days ago

At the time, thought I've solve the problem

But few days later, script don't work, I can't figure out what's going wrong

Code: Select all

GetDate>today
DateAdd>today,D,-1,yesterday

DatePart>yesterday,Y,yyyy
DatePart>yesterday,M,mm
DatePart>yesterday,D,dd

//year_part is 4 digits, so we want only last 2
//MidStr>year_part,3,2,year_bits

If{length("%dd%")<2}
Let>dd=0%dd%
Endif

If{length("%mm%")<2}
Let>mm=0%mm%
Endif

CopyFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%00.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%yyyy%%mm%%dd%00.nc
CopyFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%06.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%yyyy%%mm%%dd%06.nc
CopyFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%12.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%yyyy%%mm%%dd%12.nc
CopyFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%18.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%yyyy%%mm%%dd%18.nc
MoveFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%00.nc,Y:\CWB\WRF\NC\%yyyy%%mm%
MoveFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%06.nc,Y:\CWB\WRF\NC\%yyyy%%mm%
MoveFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%12.nc,Y:\CWB\WRF\NC\%yyyy%%mm%
MoveFile>Y:\CWB\WRF\NC\wrf%yyyy%%mm%%dd%18.nc,Y:\CWB\WRF\NC\%yyyy%%mm%

Year>Y
Month>M
Day>D

CopyFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%00.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%Y%%M%%D%00.nc
CopyFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%06.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%Y%%M%%D%06.nc
CopyFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%12.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%Y%%M%%D%12.nc
CopyFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%18.nc,D:\OceansMap20\UserEDS\NKMU\WRF\wrf%Y%%M%%D%18.nc

MoveFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%00.nc,Y:\CWB\WRF\NC\%y%%m%
MoveFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%06.nc,Y:\CWB\WRF\NC\%y%%m%
MoveFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%12.nc,Y:\CWB\WRF\NC\%y%%m%
MoveFile>Y:\CWB\WRF\NC\wrf%Y%%M%%D%18.nc,Y:\CWB\WRF\NC\%y%%m%

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Re: Copyfile and Movefile don't work

Post by zabros2020 » Sun Mar 12, 2017 5:08 am

Hi,

I highly recommend you use the absolute path name and not the mapped path.
Judging by the path you are using, looks like you a mapping to a share drive.

I'd use \\server\sharename\CWB\WRF\NC\ NOT Y:\CWB\WRF\NC\

Reason? Each user may map their share and use a different drive letter or the mapped share may fail to refresh...
Loving MS's Capabilities!!!

LE1202
Newbie
Posts: 6
Joined: Tue Feb 21, 2017 12:55 pm

Re: Copyfile and Movefile don't work

Post by LE1202 » Tue Mar 14, 2017 1:23 am

Hi, thank you for reminding to change the path to server

But I still have some trouble with get the filename

I use MessageModal to check the date that macro return

As an example, it return "wrf20170301318.nc" as result, but the filename I want just "wrf2017031318.nc"

I've try to fix the code to If{length("%dd%")=1}, but it still don't work

Code: Select all

If{length("%dd%")<2}
Let>dd=0%dd%
Endif

If{length("%mm%")<2}
Let>mm=0%mm%
Endif

MessageModal>wrf%yyyy%%mm%%dd%18.nc


zabros2020 wrote:Hi,

I highly recommend you use the absolute path name and not the mapped path.
Judging by the path you are using, looks like you a mapping to a share drive.

I'd use \\server\sharename\CWB\WRF\NC\ NOT Y:\CWB\WRF\NC\

Reason? Each user may map their share and use a different drive letter or the mapped share may fail to refresh...

zabros2020
Pro Scripter
Posts: 70
Joined: Sun May 03, 2009 11:49 pm
Location: AU

Re: Copyfile and Movefile don't work

Post by zabros2020 » Tue Mar 14, 2017 1:44 am

Right, I see your issue. You are missing the assignment character for your if's (>) and resulting in true statement every time..

Change your if statement from this:
If{length("%dd%")<2}
Let>dd=0%dd%
Endif
If{length("%mm%")<2}
Let>mm=0%mm%
Endif

To this:

Code: Select all

If>{length("%dd%")<2}
Let>dd=0%dd%
Endif
If>{length("%mm%")<2}
Let>mm=0%mm%
Endif
Loving MS's Capabilities!!!

LE1202
Newbie
Posts: 6
Joined: Tue Feb 21, 2017 12:55 pm

Re: Copyfile and Movefile don't work

Post by LE1202 » Tue Mar 14, 2017 3:52 am

Thank you so much, it work !! :D :D :D

zabros2020 wrote:Right, I see your issue. You are missing the assignment character for your if's (>) and resulting in true statement every time..

Change your if statement from this:
If{length("%dd%")<2}
Let>dd=0%dd%
Endif
If{length("%mm%")<2}
Let>mm=0%mm%
Endif

To this:

Code: Select all

If>{length("%dd%")<2}
Let>dd=0%dd%
Endif
If>{length("%mm%")<2}
Let>mm=0%mm%
Endif

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