Batch file to synchronize folders over a network

Status
Not open for further replies.

poertner_1274

Posts: 3,874   +3
Right now I've got a batch file to backup from My Documents to a networked drive at work. But I was wondering if there was a way to do this, but check to see if a file has been deleted. I have gotten rid of some files in my documents and they are still on my network drive. If I don't delete them from both at the same time I forget which ones they are.
Anyway, I know this is possible with a 3rd party software, but I wanted to get it done throught his batch file if at all possible, since it is a work computer and I'm not supposed to install anything onto it :evil:

This is what I am currently using.

@echo off
:: variables
set drive=j:\
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up My Documents...
%backupcmd% "%USERPROFILE%\My Documents" "%drive%"

:: use below syntax to backup other directories...
:: %backupcmd% "...source directory..." "%drive%\...destination dir..."

echo Backup Complete!
@pause
 
You would not need that at all, if you would set the J-drive's %USERPROFILE%\My Documents as your default in your PC.
(unless your network is slooooowww, or not always available).

Check if your company has Ontrack's (or V-Com's now) Powerdesk (Explorer replacement) available, that has built-in folder synchronisation. Laplink can do the same.

Your current batchfile cannot do that, there are simply no switches for that in xcopy.
 
hi,
i dont think xcopy supports network, though:
1. (if you can) program in VB then you can use the built in functons and make a full standalone app or even an invisible app....
2. (alternative) make it copy to a big data stick/hdd with all the backup stuff on it
3. you could setup mirroring im not entirly sure who or where youcan get the service it just exists....

j4m32,
 
Thanks for the suggestions, I don't think an open source program would be a problem. I'll give that a look, but I think I have figured out how I will do it. It's not efficient, but it works.
 
Poertner;
My Batch work is rusty ,but I do have a command line /Scipt manual .So I will look this up if you want me to.
In the meantime,If these files(the ones you want to delete) always have the same name or can sit in the same Directory( Therefore you can state them as a variable) You can parse for their existence, then Goto your Xcopy command
eg.
for iterator (initialization variable and a set of files to execute against) do (Command)
If I understand your needs correctly this should work.
 
Status
Not open for further replies.
Back