title: Excluding folders in Winrar
body: <p><strong>A Day with Winrar</strong></p>
  
  <p>All I wanted to do was exclude folders and their contents using wildcards, and even after reading the docs, it turned into a guessing game...</p>
  
  <p>So my test bed looks like:</p>
  
  <pre><code>C:\!tmp1\f1
  C:\!tmp1\f1\f1.txt
  C:\!tmp1\f1\a
  C:\!tmp1\f1\a\a.txt
  C:\!tmp1\f2
  C:\!tmp1\f2\f2.txt
  C:\!tmp1\f2\a
  C:\!tmp1\f2\a\a.txt
  </code></pre>
  
  <p>And I am executing:</p>
  
  <pre><code>C:\&gt;"c:\program files\winrar\winrar.exe" a -r !tmp1.rar !tmp1
  </code></pre>
  
  <p>which gives me a rar with !tmp1 as the root (sole top level folder).</p>
  
  <p>The exclude switch is <code>-x&lt;filepathpattern&gt;</code> and may be included multiple times.</p>
  
  <p>So, given that we want to exclude f2, and all its subcontents...</p>
  
  <pre><code>-x*\f2\*
  </code></pre>
  
  <p>removes the contents, but leaves f2</p>
  
  <pre><code>-xf2
  </code></pre>
  
  <p>does nothing - includes all</p>
  
  <pre><code>-x\f2
  </code></pre>
  
  <p>does nothing - includes all</p>
  
  <pre><code>-x*\f2
  </code></pre>
  
  <p>does nothing - includes all (now I'm mad), so surely it must be..</p>
  
  <pre><code>-x\f2\
  </code></pre>
  
  <p>nope, does nothing - includes all. So it has GOT to be...</p>
  
  <pre><code>-x*\f2\
  </code></pre>
  
  <p>hell no, does nothing - includes all. and I already know that</p>
  
  <pre><code>-x*\f2\*
  </code></pre>
  
  <p>removes the contents, but leaves f2. Onward we go...</p>
  
  <pre><code>-x*f2\
  </code></pre>
  
  <p>does nothing - includes all. Grrrr. Aha! how about...</p>
  
  <pre><code>-x!tmp1\f2\
  </code></pre>
  
  <p>nope, does nothing - includes all. WTF. Alright, So it has GOT to be...</p>
  
  <pre><code>-x!tmp1\f2
  </code></pre>
  
  <p>Holy moly, it worked! Hmmm, then how come....</p>
  
  <pre><code>-x*\f2
  </code></pre>
  
  <p>does not work? <strong><em>This was the little demon that sent me down this crazed path to begin with and should have worked!</em></strong></p>
  
  <p>Given all that, do I dare try to go after <code>*/a/*</code> directories, removing contents and the dirs?</p>
  
  <pre><code>-x*\a
  </code></pre>
  
  <p>does not work, of course, does nothing.</p>
  
  <pre><code>-x*\*\a
  </code></pre>
  
  <p>does not work, of course, does nothing.</p>
  
  <pre><code>-x!tmp1\*\a
  </code></pre>
  
  <p>nope. But...</p>
  
  <pre><code>-x*\a\*
  </code></pre>
  
  <p>removes contents of both dirs, but leaves the folders. So, in desperation I can use the <code>-ed</code> switch which will not store empty folders, but this is a broad hack, I want to eliminate the folders specified not all empty folders.</p>
  
  <p>With my animosity growing toward winrar, I am passing the baton of information forward with an eye to that glorious day when we will know how to specifically exclude a folder and its contents using wildcards and not using the <code>-ed</code> switch.</p>