Copy a directory tree under Windows XP Vista Seven

Discussion in 'Scripting' started by renoOo, Apr 30, 2012.

  1. renoOo

    renoOo MDL Novice

    Jan 29, 2011
    #1 renoOo, Apr 30, 2012
    Last edited: Apr 30, 2012
    Tip to copy the directory tree under Windows XP Vista Seven

    I have 2 NAS at home (System and User) and a Mediacenter (video NAS).

    When I'm not (often) at home, I use my laptop and I always downloads new files or people give me a lot.
    Then I backup my NAS directories but never correspond with my backup software (SynBackPro) and I forget the name of directories and files stored on my NAS.:eek:

    I decided that the best way to manage my backups is to copy on the hard drive of my laptop the directory tree of my NAS without copying files.

    I tried using xcopy but I had known the problems of those old DOS commands (insufficient memory, directories not copied, slow ...) :mad:
    xcopy source target / I / T / E / Z

    The solution is robocopy (Robust File and Folder Copy => Standard Windows 7/Vista command) that is available in Seven / Vista and XP/2003 (XP Resource Kit).

    Here is my code to copy directories on my laptop.
    Creates \ _NAS \ directory.NAS on HD

    @echo off
    set NAS1=\\dns323
    set HD=D:
    set arbre=_NAS
    set ext1=%NAS1:~2%
    for %%a in (old_system materiel system hotfix) do (
    robocopy %NAS1%\%%a %HD%\%arbre%\%%a.%ext1% /S /E /CREATE /NP /LOG+:"%HD%\log.txt" /XF *.* /R:3 /W:1 /XA:RASHCNETO

    Fantastic, it works and in addition, there is a LOG file.
    I can now save files on my laptop and save them in the right directories of my NAS, then use my backup software.