سؤال

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 ?

هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top