Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Exclude specific folders relative to root folder

Help
2013-02-07
2013-02-14
  • Zero Sinner
    Zero Sinner
    2013-02-07

    Sorry, if this is a duplicate. Not sure if it went through the first time...

    I'm trying to 7z a directory through the command line on windows. I'm
    trying to exclude specific folders.

    My structure:

    \ \Project\A (I want this to be excluded)
    \Project\B (this too)
    \Project\C
    \Project\C\A
    \Project\C\B
    \Project\C\Project\A

    In the example above all are directories.

    If I add -xr!A -xr!B it excludes \Project\C\A and B as well. If I do
    -xr!Project\A it excludes \Project\C\Project\A

    Is there anyway to exclude only those specific folders from within 7zip? My
    only other option is to make a script to temporarily remove the folders in
    question and then run the 7z command with no exclusions.

    Thanks for your help :),
    ~0

     
  • fernando
    fernando
    2013-02-07

    try...
    7z a archive Project -x!Project\A -x!Project\B

    example...

    $ dir/s/b
    Z:\Project
    Z:\Project\A
    Z:\Project\B
    Z:\Project\C
    Z:\Project\C\A
    Z:\Project\C\B
    Z:\Project\C\Project
    Z:\Project\C\Project\A
    
    $ 7z a archive Project -x!Project\A -x!Project\B
    
    7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
    Scanning
    
    Creating archive archive.7z
    
    Everything is Ok
    
    $ 7z t archive.7z
    
    7-Zip 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
    
    Processing archive: archive.7z
    
    Testing     Project\C\Project\A
    Testing     Project\C\Project
    Testing     Project\C\B
    Testing     Project\C\A
    Testing     Project\C
    Testing     Project
    
    Everything is Ok
    
    Folders: 6
    Files: 0
    Size:       0
    Compressed: 149
    
    $
    
     
  • Zero Sinner
    Zero Sinner
    2013-02-14

    For some reason I thought it was excluding \Project\C\Project\A as well. But I guess not.

    Ok, so paths are absolute relative to the root?

     
  • fernando
    fernando
    2013-02-14

    recall that recurse subdirectories is disabled by default.
    so we only match exclusion in first level directory.
    you overrode recursion when you used the -r switch.