Python calls 7zip command to implement file batch decompression
1. Enter the path where the compressed file is located
2. You can modify the extracted file path and the type of decompression required in the code, include, unzip all the files in the MP4 format below the folder.
3.cmd refers to the python call DOS command, followed by the x-r these are all reference 7zip use book, and extract folders under all the MP4 end of the file, put the file into e-disk, test the new folder under the Decompression folder
#call the 7z command to extract files in bulkImportOsfolder_name= Input ("Please enter a folder:") Os.chdir (folder_name) file_names= Os.listdir ("./") forNameinchFile_names:Print("is not a file:", Os.path.isfile (name))ifos.path.isfile (name): Name=Os.path.abspath (name)#returns a tuple, the second element of a tuple is an extension ifOs.path.splitext (name) [1] = =". zip": cmd='\ "C:\\Program files\\7-zip\\7z.exe\" x \ "{0}\"-oe:/test decompression/new *.mp4-r'. Format (name) os.popen (CMD)
Python calls 7zip command for decompression