Help extracting comment data from multiple zip files - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Help extracting comment data from multiple zip files (/thread-12717.html) Pages:
1
2
|
RE: Help extracting comment data from multiple zip files - SoulsKeeper - Sep-10-2018 (Sep-09-2018, 12:42 PM)snippsat Wrote:sorry for the delay, i already solved it but now i realize that i need it for Rar files and not Zip files, what do i need to change to get the same effect?(Sep-09-2018, 12:21 PM)SoulsKeeper Wrote: solved it by using the the other slash(/)You had it right in first post then you forgot import unicodedata from zipfile import ZipFile rootFolder = u"C:/Users/user/Desktop/archives/" zipfiles = [os.path.join(rootFolder, f) for f in os.listdir(rootFolder)] for zfile in zipfiles: print("Opening: {}".format(zfile)) with ZipFile(zfile, 'r') as testzip: print(testzip.comment) # comment for entire zip l = testzip.infolist() #list all files in archive for finfo in l: # per file/directory comments print("{}:{}".format(finfo.filename, finfo.comment)) |