|
Answer» Hi there, I've had a search through the forum and couldn't find anything specific to my query but if there is already a post related to it I'd be happy to be pointed in the right direction.
At work I have a folder on my C drive which I use to store Excel, PowerPoint & Word Documents, as well as lots of .jpg image files that I use. I have a batch file that I use so that I can copy the contents of this folder to a location on the company server where people can access it.
The batch command for this file is as follows (I have REMOVED the exact names and locations of the folder):
@echo off
xcopy "C:\Location" "G:\Location" /D /E /Y
This command allows me to automatically copy all additional files or edited files to the desired location by simply running the command as expected.
What I would like to do though is have files that are no longer in the source folder (ones on C drive) removed from the destination folder (ones on G drive). The reason for this is that the destination folder on the company server is gradually creeping up in size and I don’t see any need for it. All I need is for the 2 folders to be synced so that they contain the exact same INFO. I believe this would involve a delete command but I am unsure how to go about this.
Ideally I think Robocopy is what is used for this sort of thing but I have contacted my IT department and have not had any feedback yet so would like to see if I could try something out myself.
I'll just add that I am not very experienced in using command prompts so would appreciate if you could explain things in laymen’s terms
Many Thanks
TS
C:\test>comp /? Compares the contents of two files or sets of files.
COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[liNE]]
data1 Specifies location and name(s) of first file(s) to compare. data2 Specifies location and name(s) of second files to compare. /A Displays differences in ASCII characters. To compare sets of files, use wildcards in data1 and data2 parameters.
C:\test>dir m*.bat Volume in drive C has no label. Volume Serial Number is 0652-E41D
Directory of C:\test
04/27/2010 12:03 PM . 04/27/2010 12:03 PM .. 04/24/2010 02:39 PM 199 matt.bat 04/25/2010 11:27 AM 260 matt2.bat 04/25/2010 11:34 AM 307 matt3.bat 04/25/2010 11:41 AM 224 matt4.bat
C:\test>copy matt2.bat matt5.bat 1 file(s) copied.
C:\test>comp matt2.bat matt5.bat Comparing matt2.bat and matt5.bat... Files compare OK
Compare more files (Y/N) ? n
C:\test>Here is some information that may help. But it is not abut batch files. It is about how to keep a local drive and a network drive in sync. How to use offline files in Windows XPThanks for the info guys but I have already solved the issue.
I ended up using the following command:
robocopy "source" "destination" /mir /z
TSQuote Robocopy.exe: ROBUST File Copy Utility Overview The Microsoft® Windows® Server 2003 Resource Kit Tools are a set of tools to help administrators streamline management tasks such as troubleshooting operating system issues, MANAGING Active Directory®, configuring networking and security features, and automating application deployment.
Windows Server 2003 Resource Kit ToolsQuote from: Geek-9pm on April 28, 2010, 11:12:25 AMWindows Server 2003 Resource Kit Tools
it also comes with Vista and Windows 7 by default.
|