Question

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 ?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top