Example:
I have a spreadsheet tool that is dependent on external daily report files. They get stored to a server that has no effective directory management; so, the files for the entire year are just dumped into one folder. Thankfully, the server has decent naming strings so you can figure out what the report is by reading the file name. So, a report that was created on May 5th, 2013 at center 2501 gets named this way: Summary_0A10751_2501_2013-05-05.
I already have the script to create the annual directory folder containing all the months and the days for each month:
Code: Select all
@echo off & setlocal
set year=%1
if "%year%"=="" set /p year=Year?
if "%year%"=="" goto :eof
set /a mod=year %% 400
if %mod%==0 set leap=1 && goto :mkyear
set /a mod=year %% 100
if %mod%==0 set leap=0 && goto :mkyear
set /a mod=year %% 4
if %mod%==0 set leap=1 && goto :mkyear
set leap=0
:mkyear
call :mkmonth 01 Jan 31
call :mkmonth 02 Feb 28+leap
call :mkmonth 03 Mar 31
call :mkmonth 04 Apr 30
call :mkmonth 05 May 31
call :mkmonth 06 Jun 30
call :mkmonth 07 Jul 31
call :mkmonth 08 Aug 31
call :mkmonth 09 Sep 30
call :mkmonth 10 Oct 31
call :mkmonth 11 Nov 30
call :mkmonth 12 Dec 31
goto :eof
:mkmonth
set month=%1
set mname=%2
set /a ndays=%3
for /l %%d in (1,1,9) do mkdir %year%\%month%-%mname%\%month%-0%%d
for /l %%d in (10,1,%ndays%) do mkdir %year%\%month%-%mname%\%month%-%%d
And the script to pull new reports daily from the server and place them in a folder on the local drive:
Code: Select all
ECHO [message]
XCOPY "X:\Center Reports\Financials\Center Summary Reports" "C:\Users\Dude\Desktop\Financial Tracker\Center Summary Reports" /D /E /C /R /I /K /Y
But is there a way to otherwise combine these and add a subroutine that will look at the file names on the server and match the date and then xcopy it in the proper date folder? Or do I need a third script altogether?