xcopy in batch script

minion

Well-Known Member
Joined
May 31, 2011
Messages
218
Reaction score
0
hey guys! there is no script board so i posted this in software :D

how many of you still use xcopy? if so have you ever had success with xcopy in batch script? i copy whole lot of files (part of DR project), but i found if i use more than 1 line for xcopy then it doesnt complete successfully, any advice? am i missing something?
 
Something like this?

SET SOURCEFOLDER=C:\
SET TARGETFOLDER=C:\TEMP
FOR %%F IN (file1 file2 file3) DO (XCOPY /Y /F /R %SOURCEFOLDER%\%%F %TARGETFOLDER% )
 
Something like this?

SET SOURCEFOLDER=C:\
SET TARGETFOLDER=C:\TEMP
FOR %%F IN (file1 file2 file3) DO (XCOPY /Y /F /R %SOURCEFOLDER%\%%F %TARGETFOLDER% )

nope more like...

net stop 'services'
net stop 'services'
net stop 'services'
xcopy 'source' 'destination' 'switches'
xcopy 'source' 'destination' 'switches'
xcopy 'source' 'destination' 'switches'
xcopy 'source' 'destination' 'switches'
xcopy 'source' 'destination' 'switches'
xcopy 'source' 'destination' 'switches'
net start 'services'
net start 'services'
net start 'services'
 
I have had a bad time with robocopy where after continuous use I started getting unexpected results where the LEFT and the RIGHT weren't syncing properly. In particular new files on the left were being synced correctly to the right but on occasion folder deletes on the LEFT were't mirrored on the right. I am sure I had overlooked something. In the end though I went through extremes and installed Cygwin in order to use the only command-line mirroring command I was familiar with from Linux -> rsync.
 
Oh dear, i really should read before I post. When I read 'Robocopy' i confused it with 'SyncToy'.
No issues with Robocopy.
 
hey guys! there is no script board so i posted this in software :D

how many of you still use xcopy? if so have you ever had success with xcopy in batch script? i copy whole lot of files (part of DR project), but i found if i use more than 1 line for xcopy then it doesnt complete successfully, any advice? am i missing something?

Why does it not complete successfully?, which error message do you receive?
 
Why does it not complete successfully?, which error message do you receive?

I bet it fails with its very descriptive usual error "insufficient memory" :-)

xcopy cant take more than 254 characters in a path, which makes it useless, if you try to copy something as simple as someones WindowsXP/Win7 Profile folder it fails.

robocopy AKA Robust Copy is way better and also has better copy functions.
 
I bet it fails with its very descriptive usual error "insufficient memory" :-)

xcopy cant take more than 254 characters in a path, which makes it useless, if you try to copy something as simple as someones WindowsXP/Win7 Profile folder it fails.

robocopy AKA Robust Copy is way better and also has better copy functions.

I'm to lazy to google now, does RoboCopy work in dos?, because i think the OP needs to use it in a batch file.
The /C command should force it to continue copying, if there are certain files/folders thats giving errors the /Exclude command can also be used.
 
I'm to lazy to google now, does RoboCopy work in dos?, because i think the OP needs to use it in a batch file.
The /C command should force it to continue copying, if there are certain files/folders thats giving errors the /Exclude command can also be used.




Yes it does, also you can execute most applications from a batch file, they don't have to work in command prompt.
 
Like others, I've used robocopy for years. Daily. In schedule-invoked batch files.

All user data is robocopied nightly to two physical drives, then imaged with Acronis Backup and Recovery 11.5 Advanced. That image is then replicated to another machine in a different building.

C:/>robocopy /? for parameters and switches

Use the +log switch to write a record of all robocopied files to a txt file.
 
Last edited:
Yes it does, also you can execute most applications from a batch file, they don't have to work in command prompt.

Yeah i know, but when giving/using commands it needs to be able to run in/from Dos.
I always used Total Copy, but its windows based.
 
Here are the relevant parts of a typical robocopy batch file I use:

Code:
@echo off
@echo ROBOCOPY SERVER DATA, PHOTOS from SERVER Drive D to this computer G:\Data ...
@echo. 
@echo. 
set varline=***********************************************
@echo. >> g:\COPY_HISTORY.LOG
echo %varline% >> g:\COPY_HISTORY.LOG
set varstart=START COPY: %date% %time%
echo %varstart% >> g:\COPY_HISTORY.LOG
@echo. >> g:\COPY_HISTORY.LOG
robocopy \\source-sharename\folder g:\destination-dir /EFSRAW /XO /TIMFIX /NDL /MIR /R:5 /NP /TEE /NJH /NJS /LOG+:g:\COPY_HISTORY.LOG
robocopy \\Server\Media\Photographs g:\Photographs /EFSRAW /XO /TIMFIX /NDL /MIR /R:5 /NP /TEE /NJH /NJS /LOG+:g:\COPY_HISTORY.LOG
set varend=END COPY: %date% %time%
@echo. >> g:\COPY_HISTORY.LOG
echo %varend% >> g:\COPY_HISTORY.LOG
 
Yeah i know, but when giving/using commands it needs to be able to run in/from Dos.
I always used Total Copy, but its windows based.

robocopy has no GUI its purly command based, its not like total copy at all. and it wont work in DOS either :-) but in the Windows Command prompt, ;-)
 
Top
Sign up to the MyBroadband newsletter
X