Copy newest subfolder

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Magbert
Newbie
Posts: 2
Joined: Wed Nov 08, 2006 2:23 pm

Copy newest subfolder

Post by Magbert » Wed Nov 08, 2006 3:47 pm

Hello

I am trying to accomplish the following:

I automatically create some reports from a database every night. These Reports are copied to a Reports/YYYYMMDD-HH-MM Folder.

I would now like to use Macro Scheduler to copy the latest subfolder from the reports folder to another location.

Can anybody help me?

Regards

Magbert

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

Post by JRL » Wed Nov 08, 2006 5:03 pm

You could try something like this. change the value of "sourcepath" and "destinationpath" to reflect your setup. Change RP_WINDOWMODE to 0 or 2 to avoid seeing the DOS window. to understand the dir and xcopy switches, open a DOS window and type dir /? or xcopy /?.

Hope this helps,
Dick

Code: Select all

Let>sourcepath=[drive]:\path\report
Let>destinationpath=[drive]:\path
Let>tempfile=%TEMP_DIR%~tempdirlist~.txt
Let>RP_WAIT=1
Let>RP_WINDOWMODE=1
Run>cmd /c dir %sourcepath% /b /o-d /ad > %tempfile%
ReadLn>%tempfile%,1,NewestDirectory
CreateDir>%destinationpath%\%NewestDirectory%
Run>cmd /c xcopy "%sourcepath%\%NewestDirectory%" "%destinationpath%"\%NewestDirectory% /e

Magbert
Newbie
Posts: 2
Joined: Wed Nov 08, 2006 2:23 pm

Post by Magbert » Wed Nov 08, 2006 6:38 pm

Thank you very much for your help! It worked perfectly! :lol:

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