Tim said:
I have to copy few files daily to a central server from
local W2K server to a remote share on W2K server.
Presently a batch file takes care of this copy. The issue
is I have to pre-create various folders ready on the
destination based on currenmt system date before the
copy, such as:
G:\...\SEP2004\
G:\.....\26SEP\
G:\..\26SEP04\
How to automate this process? (Something like, if not
exist MD G:\....\XXXXX\ based on current system date)
I'd use date time functions from Ritchie Lawrence batch linrary at
http://www.commandline.co.uk
@echo off
setlocal
call :GetDate yy mm dd
call :MonthName %mm% month
echo Year : %yy%
echo Month: %mm% %month%:~0,3% %month%
echo Day : %dd%
goto :eof
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:GetDate yy mm dd
::
:: By: Ritchie Lawrence, 2002-06-15. Version 1.0
::
:: Func: Loads local system date components into args 1 to 3.
:: For NT4/2000/XP/2003.
::
:: Args: %1 var to receive year, 4 digits (by ref)
:: %2 var to receive month, 2 digits, 01 to 12 (by ref)
:: %3 Var to receive day of month, 2 digits, 01 to 31 (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS
set t=2&if "%date%z" LSS "A" set t=1
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do (
for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do (
set %%a=%%d&set %%b=%%e&set %%c=%%f))
endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:MonthName %mm% month
::
:: By: Ritchie Lawrence, 2002-10-04. Version 1.0
::
:: Func: Returns the name of month from the number of the month.
:: For NT4/2000/XP/2003.
::
:: Args: %1 month number convert to name, 1/01 to 12 (by val)
:: %2 var to receive name of month (by ref)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal ENABLEEXTENSIONS&set /a m=100%1%%100
for /f "tokens=%m%" %%a in ('echo/January February March April May^
June July August September October November December'
) do endlocal&set %2=%%a&goto :EOF
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::