I have 95 folders filled with only .rar
I want to extract those folder with a little script :
import os
import rarfile
parent_directory = 'E:\Immo_JSON'
destination_directory = 'E:\OP'
for folder in os.listdir(parent_directory):
folder_path = os.path.join(parent_directory, folder)
if os.path.isdir(folder_path):
num_rar_files = 0
with os.scandir(folder_path) as entries:
for entry in entries:
if entry.is_file() and entry.name.endswith('.rar') and rarfile.is_rarfile(entry):
num_rar_files += 1
print(f"{num_rar_files} .rar found in the folder {folder}")
I included a printf to show me if he found .rar inside those folder and it returns 0 for each folder.
There are only .rar inside those folders, not password protected and not corrupted since I can extract them manually. Any ideas ?