Batch file to synchronize folders over a network

By poertner_1274 ยท 6 replies
May 17, 2005
  1. 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!
  2. RealBlackStuff

    RealBlackStuff TS Rookie Posts: 6,503

    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.
  3. j4m32

    j4m32 TS Rookie Posts: 49

    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....

  4. andygibbs

    andygibbs TS Enthusiast Posts: 60

  5. poertner_1274

    poertner_1274 secroF laicepS topShceT Topic Starter Posts: 4,172

    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.
  6. Liquidlen

    Liquidlen TechSpot Paladin Posts: 1,094

    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
    for iterator (initialization variable and a set of files to execute against) do (Command)
    If I understand your needs correctly this should work.
  7. patio

    patio TS Guru Posts: 482


    patio. :cool:
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...