Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Help with /EXCLUDE switch oc xcopy command

  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with /EXCLUDE switch oc xcopy command

    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:

    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:

    \\London\SourceFolder\master\bin_debug\Event Table
    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:
    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:

    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:

    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:
    doesn’t have effect... What I missing?
    Last edited by igor7; 20th June 2010, 08:37.