|
View Full Version : calling xcopy from vbs file?
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???
|
John Smith wrote: > > 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??? Hi
dDate = FormatDateTime(Now, 2)
Set WshShell = CreateObject("WScript.Shell") sCmd = "test.bat " & CStr(dDate) WshShell.Run sCmd, 1
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/community/scriptcenter/default.mspx
|
John Smith wrote: [color=blue] > 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??? > > >[/color]
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
|
"John Smith" wrote: [color=blue] >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 >[/color] You could also use xxcopy. [url]www.xxcopy.com[/url] (Free for pivate use)
the option /DA#0 or /DA:. will do without any calculations.
-- Greetings Matthias
|
Would that work in October?
"Phil Robyn [MVP]" wrote in message news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl...[color=blue] > John Smith wrote: >[color=green] > > I want to be able to create a batch file that will run daily and only[/color][/color] move[color=blue][color=green] > > 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[/color][/color] have[color=blue][color=green] > > 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[/color][/color] and it[color=blue][color=green] > > works fine. but not the test.vbs. > > Does anyone have any suggestions??? > > > > > >[/color] > > 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[/color]
|
If you just pass the /D switch without anything after it, then it will only copy files that are newer than the target.
"John Smith" wrote in message news:1061lngs24750eb@corp.supernews.com...[color=blue] > 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[/color] it[color=blue] > works fine. but not the test.vbs. > Does anyone have any suggestions??? > > >[/color]
|
Bonj wrote: [color=blue] > Would that work in October?[/color]
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?
[color=blue] > > "Phil Robyn [MVP]" wrote in message > news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl... >[color=green] >>John Smith wrote: >> >>[color=darkred] >>>I want to be able to create a batch file that will run daily and only[/color][/color] > > move >[color=green][color=darkred] >>>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[/color][/color] > > have >[color=green][color=darkred] >>>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[/color][/color] > > and it >[color=green][color=darkred] >>>works fine. but not the test.vbs. >>>Does anyone have any suggestions??? >>> >>> >>>[/color] >> >>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[/color] > > >[/color]
-- 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
|
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....
"Phil Robyn [MVP]" wrote in message news:%23is$yVrEEHA.2768@tk2msftngp13.phx.gbl...[color=blue] > Bonj wrote: >[color=green] > > Would that work in October?[/color] > > 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? > >[color=green] > > > > "Phil Robyn [MVP]" wrote in message > > news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl... > >[color=darkred] > >>John Smith wrote: > >> > >> > >>>I want to be able to create a batch file that will run daily and only[/color] > > > > move > >[color=darkred] > >>>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[/color] > > > > have > >[color=darkred] > >>>the current date. So, I tried to create a .vbs that would call the[/color][/color][/color] xcopy[color=blue][color=green][color=darkred] > >>>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[/color] > > > > and it > >[color=darkred] > >>>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[/color] > > > > > >[/color] > > > -- > 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[/color]
|
Bonj wrote: [color=blue] > 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....[/color]
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. [color=blue] > > "Phil Robyn [MVP]" wrote in message > news:%23is$yVrEEHA.2768@tk2msftngp13.phx.gbl... >[color=green] >>Bonj wrote: >> >>[color=darkred] >>>Would that work in October?[/color] >> >>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? >> >> >>[color=darkred] >>>"Phil Robyn [MVP]" 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[/color][/color] > > xcopy >[color=green][color=darkred] >>>>>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 >>> >>> >>>[/color] >> >>-- >>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[/color] > > >[/color]
-- 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
|
John Smith wrote: > > 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??? Hi
dDate = FormatDateTime(Now, 2)
Set WshShell = CreateObject("WScript.Shell") sCmd = "test.bat " & CStr(dDate) WshShell.Run sCmd, 1
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/community/scriptcenter/default.mspx
|
John Smith wrote: [color=blue] > 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??? > > >[/color]
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
|
"John Smith" wrote: [color=blue] >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 >[/color] You could also use xxcopy. [url]www.xxcopy.com[/url] (Free for pivate use)
the option /DA#0 or /DA:. will do without any calculations.
-- Greetings Matthias
|
Would that work in October?
"Phil Robyn [MVP]" wrote in message news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl...[color=blue] > John Smith wrote: >[color=green] > > I want to be able to create a batch file that will run daily and only[/color][/color] move[color=blue][color=green] > > 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[/color][/color] have[color=blue][color=green] > > 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[/color][/color] and it[color=blue][color=green] > > works fine. but not the test.vbs. > > Does anyone have any suggestions??? > > > > > >[/color] > > 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[/color]
|
If you just pass the /D switch without anything after it, then it will only copy files that are newer than the target.
"John Smith" wrote in message news:1061lngs24750eb@corp.supernews.com...[color=blue] > 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[/color] it[color=blue] > works fine. but not the test.vbs. > Does anyone have any suggestions??? > > >[/color]
|
Bonj wrote: [color=blue] > Would that work in October?[/color]
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?
[color=blue] > > "Phil Robyn [MVP]" wrote in message > news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl... >[color=green] >>John Smith wrote: >> >>[color=darkred] >>>I want to be able to create a batch file that will run daily and only[/color][/color] > > move >[color=green][color=darkred] >>>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[/color][/color] > > have >[color=green][color=darkred] >>>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[/color][/color] > > and it >[color=green][color=darkred] >>>works fine. but not the test.vbs. >>>Does anyone have any suggestions??? >>> >>> >>>[/color] >> >>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[/color] > > >[/color]
-- 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
|
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....
"Phil Robyn [MVP]" wrote in message news:%23is$yVrEEHA.2768@tk2msftngp13.phx.gbl...[color=blue] > Bonj wrote: >[color=green] > > Would that work in October?[/color] > > 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? > >[color=green] > > > > "Phil Robyn [MVP]" wrote in message > > news:ujWuUoTEEHA.2076@TK2MSFTNGP09.phx.gbl... > >[color=darkred] > >>John Smith wrote: > >> > >> > >>>I want to be able to create a batch file that will run daily and only[/color] > > > > move > >[color=darkred] > >>>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[/color] > > > > have > >[color=darkred] > >>>the current date. So, I tried to create a .vbs that would call the[/color][/color][/color] xcopy[color=blue][color=green][color=darkred] > >>>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[/color] > > > > and it > >[color=darkred] > >>>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[/color] > > > > > >[/color] > > > -- > 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[/color]
|
Bonj wrote: [color=blue] > 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....[/color]
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. [color=blue] > > "Phil Robyn [MVP]" wrote in message > news:%23is$yVrEEHA.2768@tk2msftngp13.phx.gbl... >[color=green] >>Bonj wrote: >> >>[color=darkred] >>>Would that work in October?[/color] >> >>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? >> >> >>[color=darkred] >>>"Phil Robyn [MVP]" 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[/color][/color] > > xcopy >[color=green][color=darkred] >>>>>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 >>> >>> >>>[/color] >> >>-- >>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[/color] > > >[/color]
-- 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
|
|
|
|