I wrote a function earlier that would take content from an @filelist and compress it all into a single file. I figured that the same would be useful when decompressing from a series of files within a folder. However when I try to run the function, I end up receiving the following error
(b’\r\n7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21\r\n\r\nScanning the drive for archives:\r\n\r\nERROR: The system cannot find the file specified.\r\[email protected]\r\n\r\n\r\n\r\nSystem ERROR:\r\nThe system cannot find the file specified.\r\n’,
Don’t know why this happens as the compression side works fine like this and the generated filelist is simply a listdir() of the folder in question.
def Decompress_7z(Initial_path,File_List,DAE = False): """ DAE : Delete After Extraction - Remove Container after extracting contents """ try: chdir(Initial_path) except: return('Path does not exist') # write a listfile with open('list.txt', 'w') as f: for item in File_List: f.write("%s\n" % item) cmd = ['7z', 'e', '@list.txt'] system = subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,shell=True) while system.poll() == None: # .poll() will return a value once it's complete. time.sleep(1) if DAE: for f in File_List: remove(f) # Clean up from compression # remove('list.txt') return(system.communicate())
Function is run as follows
Decompress_7z('Folder containing zip files',listdir())