Hi, I just start to use Macro Scheduler
I have some file name by YYYYMMDD.NC
These file create everyday
That mean, I have file as 20170221.nc, 20170222.nc, 20170223.nc etc.
How can I use macro to move these file to another folder ?
Thanks Help
How to move batch files ?
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: How to move batch files ?
If you want to move ALL files then just GetFileList and loop through the list.
If you only want to move all files in the folder that follow that format then use RegEx on the filenames as you loop through to see if the files are 8 digits ...
If you mean you want to move TODAY's file where the filename is today's date then:
Year>the_year
Month>the_month
Day>the_day
Let>filename=%the_year%%the_month%%the_day%.inc
MoveFile>filename,destination
You can also use date functions to get the year, month and day from some other date. So if you were moving yesterday's files for example you could do that too.
Given my answer you might want to clarify what you want to do - move ALL files that match that format, or ALL files in a folder, or a specific file given a specific date .... ??
If you only want to move all files in the folder that follow that format then use RegEx on the filenames as you loop through to see if the files are 8 digits ...
If you mean you want to move TODAY's file where the filename is today's date then:
Year>the_year
Month>the_month
Day>the_day
Let>filename=%the_year%%the_month%%the_day%.inc
MoveFile>filename,destination
You can also use date functions to get the year, month and day from some other date. So if you were moving yesterday's files for example you could do that too.
Given my answer you might want to clarify what you want to do - move ALL files that match that format, or ALL files in a folder, or a specific file given a specific date .... ??
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: How to move batch files ?
Hello Marcus Tettmar
Sorry for replying so late
I've solve my problem by using
Year>the_year
Month>the_month
Day>the_day
MoveFile>filename,destination
Thank you for your helping
Best Wishes
Sorry for replying so late
I've solve my problem by using
Year>the_year
Month>the_month
Day>the_day
MoveFile>filename,destination
Thank you for your helping
Best Wishes
Re: How to move batch files ?
Hello,
It's me again
I've some problem with copy and move the file with yesterday's date
I follow the "Using Dates & Variables"
https://www.mjtnet.com/blog/2006/01/23/ ... variables/
I set up the MACRO then, but I got error code 1032
VBSTART
VBEND
VBEval>DateAdd(“d”,-1,Date),yesterday
VBEval>Year(“%yesterday%”),yyyy
VBEval>Month(“%yesterday%”),mm
VBEval>Day(“%yesterday%”),dd
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%
=========================================================================
I fix the Macro then:
GetDate>today
DateAdd>today,D,-1,yesterday
DatePart>yesterday,Y,yyyy
DatePart>yesterday,M,mm
DatePart>yesterday,D,dd
//MessageModal>%yyyy%/%mm%/%dd%
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%
But nothing happen, I've use the MessageModeal check the year,month and date, it's the date I want, but my files didn't move or copy
================================================================================
I just figure out the Macro as following, it work
GetDate>today
DateAdd>today,D,-1,yesterday
DatePart>yesterday,Y,yyyy
DatePart>yesterday,M,mm
DatePart>yesterday,D,dd
If{length("%dd%")<2}
Let>dd=0%dd%
Endif
If{length("%mm%")<2}
Let>mm=0%mm%
Endif
It's me again
I've some problem with copy and move the file with yesterday's date
I follow the "Using Dates & Variables"
https://www.mjtnet.com/blog/2006/01/23/ ... variables/
I set up the MACRO then, but I got error code 1032
VBSTART
VBEND
VBEval>DateAdd(“d”,-1,Date),yesterday
VBEval>Year(“%yesterday%”),yyyy
VBEval>Month(“%yesterday%”),mm
VBEval>Day(“%yesterday%”),dd
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%
=========================================================================
I fix the Macro then:
GetDate>today
DateAdd>today,D,-1,yesterday
DatePart>yesterday,Y,yyyy
DatePart>yesterday,M,mm
DatePart>yesterday,D,dd
//MessageModal>%yyyy%/%mm%/%dd%
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%
But nothing happen, I've use the MessageModeal check the year,month and date, it's the date I want, but my files didn't move or copy
================================================================================
I just figure out the Macro as following, it work
GetDate>today
DateAdd>today,D,-1,yesterday
DatePart>yesterday,Y,yyyy
DatePart>yesterday,M,mm
DatePart>yesterday,D,dd
If{length("%dd%")<2}
Let>dd=0%dd%
Endif
If{length("%mm%")<2}
Let>mm=0%mm%
Endif