%date%

  • Thread starter Thread starter John Whitfield
  • Start date Start date
J

John Whitfield

Hi,

I have written a batch file that runs Ok under Windows Xp,
its a simple copy command

"xcopy c:\???\*.* c:\backupcopy\%date%\ /s /y /c" it uses
the %date% variable to create the directory structure. On
the Xp Machines when you type date from the cmd prompt you
get the date as 27/08/2003. When I do this using Win2000
server I get WED 27/08/2003 it is the addition of the WED
and space that stops the file running.

How can i change the date format? on Win2000

Thanks for your help

John
 
John Whitfield said:
get the date as 27/08/2003. When I do this using Win2000
server I get WED 27/08/2003 it is the addition of the WED
How can i change the date format? on Win2000

Don't bother, change your script so it is date format independent
by loading the date components into seperate variables, something
like:-

echo off
call :GetDate year month day
"xcopy c:\???\*.* c:\backupcopy\%day%/%month%/%year%\ /s /y /c"
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/2K/XP
::
:: 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
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
Back
Top