0

I'm trying to rar some files with the WinRAR command line. The files have this structure:

Top-Level Dir
|    Text1.txt
|    Text2.txt
|    XML1.xml
|    XML2.xml
|    Inner Dir
|    |    Inner1.txt
|    |    Inner2.txt
|    |    InnerXML1.xml
|    |    InnerXML2.xml

It's also possible for the Top-level Dir and the Inner Dir to have more subdirectories.

I can successfully rar the files and preserve the structure that I want, but I'm trying to exclude .xml files only from the top-level directory. I want my archive to look like this:

Top-Level Dir
|    Text1.txt
|    Text2.txt
|    Inner Dir
|    |    Inner1.txt
|    |    Inner2.txt
|    |    InnerXML1.xml
|    |    InnerXML2.xml

I can only manage to remove .xml files from sub-directories of Top-level Dir. Anything else I try removes all of them. I've tried a number of combinations of the following commands:

rar a -ep1 -x*.xml <destination> <source>
rar a -ep1 -x..\*.xml <destination> <source>
rar a -ep1 -r- -x*.xml <destination> <source>
rar a -ep1 -x*\..\*.xml <destination> <source>

I'm hoping that I just don't understand how specify the path correctly.

Help is appreciated.

Edit: I'm running a Windows machine.

0
$ cd <source>
$ mkdir ../tmpdir
$ mv *.xml -t ../tmpdir
$ rar a <destination> <source>
$ mv ../tmpdir/* ./
$ rmdir ../tmpdir
  • That is only a workaround. – Kevin Panko Feb 26 '14 at 15:42
  • I agree with the above comment. I should also have mentioned that I was on a Windows box (I will update the question). I did convert these commands to Windows and it does do the trick as a batch file, but it's a few more steps than I wanted. I'm still looking for something native to WinRAR. This does work though. – Brandon Feb 26 '14 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.