Announcement

Collapse
No announcement yet.

Help with /EXCLUDE switch oc xcopy command

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with /EXCLUDE switch oc xcopy command

    Hi!!
    I'm using some batch script to copy files and folders to some network location.
    Also I'm using /EXCLUDE switch to exclude folders and files that I don't need from source directory. Here is quote from the script:

    Code:
    rem # Copy backup files and folders over network
    if not exist "%destinationfolder%\" mkdir "%destinationfolder%\Backup-%dtt%"
    xcopy /s /c /i  /d /y "%sourcefolder%" "%destinationfolder%\Backup-%dtt%" /exclude:exclude.txt
    exclude.txt contains all exception. Here it is:

    Code:
    \\London\SourceFolder\User
    \\London\SourceFolder\SoftLog
    \\London\SourceFolder\SoftLogBack
    \\London\SourceFolder\SoftLogBack2
    \\London\SourceFolder\SoftLogTrouble
    \\London\SourceFolder\master\bin_debug\UIDBOUT.BTRIEVE.Back.DB
    \\London\SourceFolder\master\bin_debug\UIDBOUT.BTRIEVE.DB
    \\London\SourceFolder\master\bin_debug\Event Table
    \\London\SourceFolder\master\bin_debug\GemSetup
    \\London\SourceFolder\master\bin_debug\Maintenance
    \\London\SourceFolder\master\bin_debug\Parametr
    \\London\SourceFolder\master\bin_debug\Log\Hostlog
    \\London\SourceFolder\master\bin_debug\Log\Trace
    \\London\SourceFolder\master\bin_debug\Log\Event
    \\London\SourceFolder\master\bin_debug\temp
    \\London\SourceFolder\master\bin_debug\Log\Process
    Now, "bin_debug" folder contains many folders and files as well. I need to exclude all *.exe, *.dll, and *.sys files from being copied from "bin_debug" folder.
    I found MS article about xcopy command where saying following:
    /EXCLUDE:file1[+file2][+file3]...
    Specifies a list of files containing strings. When any of the
    strings match any part of the absolute path of the file to be
    copied, that file will be excluded from being copied. For
    example, specifying a string like \obj\ or .obj will exclude
    all files underneath the directory obj or all files with the
    .obj extension respectively.
    So, according to this explanation, I added three more lines to exclude.txt file:

    Code:
    \\London\SourceFolder\master\bin_debug\.exe
    \\London\SourceFolder\master\bin_debug\.dll
    \\London\SourceFolder\master\bin_debug\.sys
    But this doesn’t have any effect, - all exe, dll and sys files still copied from bin_debug folder... I also tried wildcard character (*) like *.exe or even *.*, but this also doesn’t have effect, - all files still copied...

    I found a solution by using "/a" switch with xcopy command (previously I removed A attribute from all files in bin_debug folder). Here is example:

    Code:
    rem # remove "A" attribute from files in folder "bin_debug"
    attrib -a %sourcefolder%\master\bin_debug\*
     
    rem # Copy backup files and folders over network
    if not exist "%destinationfolder%\" mkdir "%destinationfolder%\Backup-%dtt%"
    xcopy /s /c /i /a /y "%sourcefolder%" "%destinationfolder%\Backup-%dtt%" /exclude:exclude.txt 
     
    rem # set back "A" attribute to files in folder "bin_debug"
    attrib +a %sourcefolder%\master\bin_debug\*
    And this solution is good enough... But I can't understand why adding those lines into exclude.txt folder:
    Code:
    \\London\SourceFolder\master\bin_debug\.exe
    \\London\SourceFolder\master\bin_debug\.dll
    \\London\SourceFolder\master\bin_debug\.sys
    doesn’t have effect... What I missing?
    Last edited by igor7; 20th June 2010, 08:37.
Working...
X