Rar, Winrar - Exclude subdirectory from archive

When you pack your source code by WinRar you may want to exclude some service folders used by third-party products such as Mercurial, SVN or ReSharper. For example, you have next directory structure:

MyProject
    .hg  
    _ReSharper.MyProject
    Folder1
    Folder2
Library
    .hg
    _ReSharper.Library
    Folder1
    Folder2

where .hg is Mercurial service folder, _ReSharper.* - ReSharper service folder. You want to pack you source code without .hg and _Resharper.*. Then you command line would be like:

rar a "MyProjectAndLib.rar" -r -x*\_Resharper.*\* -x*.hg\*

where:

  • rar - winrar command line utillity
  • a - add
  • "MyProjectAndLib.rar" - destination pack file name
  • -r - pack include subdirectories
  • -x*\_Resharper.*\* - exclude _Resharper.* on any subdirectory level
  • -x*.hg\* - exclude .hg on any subdirectory level
Rating: 
Tags: