General discussion

Locked

DOS script to copy folder

By NICS ·
Hi,

This is not my forte at all, and I'm wondering if anyone has a basic script handy for Windows 2003 to copy an entire folder (inc subfolders & files)to another server each night.

So far my efforts have had a few issues - mainly that I can't delete the entire folder & then copy it back. This seemed the simplest solution but I can't get it to work.

Any sample scripts appreciated.

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Blackcurrant In reply to DOS script to copy folder

Hi

I do this everyday - I use the XCOPY command in a MS-DOS batch file to copy changed and newly created files and folders to another computer. I schedule the task to run with administrative credentials and make sure that the targets on both computers are fully accessible by the administrative account.

I use a batch file called update.bat. This copies files and folders and retains the archive bit, it also copies newly created folders to the target. The first line creates an entry in the event log and confirms that the file has started, and last line confirms that it has finished.

eventcreate /t information /id 998 /l application /d "Update.bat has started"
start /wait /b xcopy \\servername\sharename\*.* \\servername\sharename /c /d /s /e /k /y /z /i
eventcreate /t information /id 998 /l application /d "Update.bat has finished"


One word of warning: If you will be copying a large number of files and folders you will need to use XCOPY to target individual folders. Otherwise you will run out of memory - as I discovered when I tried to copy changed files from a source that was 40GB...

So, instead of just one blanket copy command you would have the following:

start /wait /b xcopy \\servername\sharename\folder1\*.* \\servername\sharename\folder1
etc etc

Also, remember to enclose the path in quote marks "" if any of your paths contain spaces.

Good luck

Collapse -

by NICS In reply to

Thanks Blackcurrant - that worked perfectly & saved me hours of work figuring it all out. Much appreciated.

Nics

Collapse -

by NICS In reply to DOS script to copy folder

Blackcurrant - that worked a treat. Thanks a million - you saved me hours of blood, sweat & tears!

Collapse -

by NICS In reply to DOS script to copy folder

This question was closed by the author

Back to Windows Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums