|
Answer» Here is a batch file that we wanted to run to copy files to our server. However, only the intial files from the directory got copies and no susequent files. .log files are created daily. We set the batch file to run in WinXp scheduler to run every 10 minutes. CAn someone help us with this?
@echo off if =="" goto error1 if "r:\test\"=="" goto error2 xcopy "c:\program files\test\*.log" "r:\test\" /y/s/e/h goto endofprogram :error1 echo you must provide source echo Syntax: echo % source destination goto endofprogram :error2 echo You must provide destination echo Syntax: echo %0 source destination goto endofprogram :endofprogram
Thanks
RicharddHey,
Having looked at your batch file it seems a little complex for just copying files.....
If you know the source and destination of these files then something like this should do the trick;
Code: [Select]@echo off
:start
xcopy "c:\program files\test\*.log" "r:\test\*.log" /y/s/e/h
if i/ "%errorlevel%" GTR "0" goto error
echo. echo. echo Copying Complete echo. echo Pressing a key will close the script pause>nul exit
:error
echo. echo. echo. echo Unable to Copying files, please check network connections. echo. echo Pressing a key will start the copying process again pause>nul goto start
I should point out that this is untested. Please make any changes that are needed, or post back I'll amend it.
Hope it helps. It seems to have got mangled, or copied by some unusual method, because it is seriously broken.
Below is my guess at how it was intended to look.
It seems to be a front end for xcopy that checks for source and destination. However, in the line that invokes xcopy, some literal folder names seem to have got substituted for the passed parameters that are plainly visible elsewhere, so the source & destination folders are now fixed, whatever parameters are supplied.
Perhaps it has been edited by an inexpert person? It certainly LOOKS that way.
How did you copy the batch file to post it on here?
@echo off if "%1"=="" goto error1 if "%2"=="" goto error2 xcopy "%1" "%2" /y/s/e/h goto endofprogram :error1 echo you must provide source echo Syntax: echo %0 source destination goto endofprogram :error2 echo You must provide destination echo Syntax: echo %0 source destination goto endofprogram :endofprogram
Sorry people, in my haste I retyped the script wrong. Here is what is actually reads: @echo off if "c:\program files\test\*.log" == "" goto error1 if "r:\test\"=="" goto error2 xcopy "c:\program files\test\*.log" "r:\test\" /y/s/e/h goto endofprogram :error1 echo you must provide source echo Syntax: echo % source destination goto endofprogram :error2 echo You must provide destination echo Syntax: echo %0 source destination goto endofprogram :endofprogram
I was trysing to do this in the BACKGROUND of XP without user input. LET me mess with your suggestions. OBTW - EXPERT I am not. In fact I know just enough to be dangerous, but little enough to be harmless.
Thanks for the help.
RicharddIs the intention to copy every file with the extension .log in the folder c:\program files\test to the folder r:\test? Yes, that is the intention. Copy all *.log files from one directory to another. I tried using /d so that only the most recent file would be copied ...but I could not get it to work. So I put in the /y to overwrite any files.
Thanks again,
Richard
|