tags:

views:

45

answers:

1

Hello,

On a Windows box, I need to extract a RAR archive so that individual files in it go into specific directories. I can provide, say, a text file that lists each file and the target directory for it. Then I need help creating a batch file that will actually extract these files into their target locations. Please help.

E.g. RAR archive x.rar contains a.a b.b c.c

Text file x.txt says a.a C:\foo b.b C:\bar c.c C:\foo

Result of running batch file on x.rar and x.txt should be: in C:\foo we have a.a and c.c in C:\bar we have b.b

Thanks!

A: 

You can pass rar a list of file names to extract with -n@<listfile>. So if you create a single file for each directory you want to extract to this should be a viable option. However, the file you describe to have doesn't quite match the format; you'd need to group it by target directory (much more fun in PowerShell by the way).

However, if the archive you're extracting is a solid archive this will take far longer since you essentially have to decompress the whole archive over and over again.

The best and probably easiest method would then probably to extract the archive once and then sort all files in their respective directories.

Joey
Thanks! Looks like it's easiest to just extract it and move the files in a batch file instead.
alonblue