Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import py7zr #downloaded this with Pip to play with 7zip files
- import os #this allows me to use the .path stuff
- #Define the paths
- downloads_folder = os.path.expanduser('~/Downloads') #the ~ signifies my home directory
- extraction_folder = os.path.expanduser('~/Romtest')
- for file_name in os.listdir(downloads_folder):
- if file_name.endswith('.7z'):
- file_path = os.path.join(downloads_folder, file_name)
- try:
- with py7zr.SevenZipFile(file_path, mode='r') as archive:
- archive.extractall(path=extraction_folder)
- print(f"Extracted: {file_name} into {extraction_folder}")
- except Exception as e:
- print(f"Failed to extract {file_name}")
- print("All files processed")
Advertisement
Add Comment
Please, Sign In to add comment