Re: calling xcopy from vbs file?
From: Phil Robyn [MVP] (zipprobyn_at_berkeley.edu)
Date: 03/25/04
- Next message: Drew Cooper [MSFT]: "Re: runas.exe not accept non-ascii passwords"
- Previous message: Bonj: "Re: calling xcopy from vbs file?"
- In reply to: Bonj: "Re: calling xcopy from vbs file?"
- Next in thread: Matthias Tacke: "Re: calling xcopy from vbs file?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Mar 2004 14:46:00 -0800
Bonj wrote:
> well, if %date% is
> 31/10/2003
> then %date:~4% is
> 0/2003
> ??
> But I've just realised it would be in mm/dd/yyyy format not dd/mm/yyyy
> format. So it would work in every month but only on the first to ninth
> days....
You're right in that the date format on a particular machine might determine
whether it would work or not. On both my Win2000 box and my WinXP box, the
format of %date% is
C:\cmd>echo %date%
Thu 03/25/2004
so '%date:~4%' will always be 'mm/dd/yyyy' regardless of what month
it happens to be (including October :-)).
If you have your machine so configured that the output of 'echo %date%'
is 'mm/dd/yyyy' rather than 'Day mm/dd/yyyy', then simply use
xcopy c:\test1 c:\test2\ /d:%date%
instead of
xcopy c:\test1 c:\test2\ /d:%date:~4%
YMMV.
Of course, %date% is not available in WinNT 4.0.
>
> "Phil Robyn [MVP]" <zipprobyn@berkeley.edu> wrote in message
> news:%23is$yVrEEHA.2768@tk2msftngp13.phx.gbl...
>
>>Bonj wrote:
>>
>>
>>>Would that work in October?
>>
>>Would *what* work in October? If you mean
>>
>> xcopy c:\test1 c:\test2\ /d:%date:~4%
>>
>>then of course it will work in October. Why wouldn't
>>it work in October?
>>
>>
>>
>>>"Phil Robyn [MVP]" <zipprobyn@berkeley.edu> wrote in message
>>>news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl...
>>>
>>>
>>>>John Smith wrote:
>>>>
>>>>
>>>>
>>>>>I want to be able to create a batch file that will run daily and only
>>>
>>>move
>>>
>>>
>>>>>files from c:\folder1 to c:\folder2 that contain today's date.
>>>>>
>>>>>xcopy c:\folder1 c:\folder2 /d:3-12-2004
>>>>>
>>>>>the above will work if I hard-code the date, but I need to be able to
>>>
>>>have
>>>
>>>
>>>>>the current date. So, I tried to create a .vbs that would call the
>
> xcopy
>
>>>>>after I put together the date:
>>>>>-----------------------------------
>>>>>test.vbs:
>>>>>
>>>>>dim dDate
>>>>>dim sString
>>>>>Dim WshShell, oExec
>>>>>
>>>>>dDate = FormatDateTime(Now, 2)
>>>>>
>>>>>Set WshShell = CreateObject("WScript.Shell")
>>>>>sString = "test.bat " & CStr(dDate)
>>>>>Set oExec = WshShell.Exec(sString)
>>>>>-----------------------------------------
>>>>>test.bat
>>>>>
>>>>>xcopy c:\test1 c:\test2 /d:%1
>>>>>---------------------------------
>>>>>
>>>>>This doesn't work. I can run test.bat 3/12/2004 from the command line
>>>
>>>and it
>>>
>>>
>>>>>works fine. but not the test.vbs.
>>>>>Does anyone have any suggestions???
>>>>>
>>>>>
>>>>>
>>>>
>>>>In this case, you really don't need test.vbs.
>>>>
>>>>
>>>>xcopy c:\test1 c:\test2 /d:%date:~4%
>>>>
>>>>--
>>>>Phil Robyn
>>>>Univ. of California, Berkeley
>>>>
>>>>u n z i p m y a d d r e s s t o s e n d e - m a i l
>>>
>>>
>>>
>>
>>--
>>Phil Robyn
>>Univ. of California, Berkeley
>>
>>u n z i p m y a d d r e s s t o s e n d e - m a i l
>
>
>
-- Phil Robyn Univ. of California, Berkeley u n z i p m y a d d r e s s t o s e n d e - m a i l
- Next message: Drew Cooper [MSFT]: "Re: runas.exe not accept non-ascii passwords"
- Previous message: Bonj: "Re: calling xcopy from vbs file?"
- In reply to: Bonj: "Re: calling xcopy from vbs file?"
- Next in thread: Matthias Tacke: "Re: calling xcopy from vbs file?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|