How to acquire extracted directory using pyUnrar2?

404 views Asked by At

I'm using pyUnrar2 to batch extract rar files, what I would like to acquire is the name of the directory that the files reside in once extracted ?

1

There are 1 answers

0
Igor Hatarist On BEST ANSWER

Extract path is set as an argument to extract().

If an archive have its own parent directory, you can grab it by using infolist():

import UnRAR2

rarc = UnRAR2.RarFile('test.rar')
list = rarc.infolist()

if list[0].isdir:
    print 'Parent directory in archive: %r' % list[0].filename