Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- # Set the paths to the folders you want to compare
- folder_a = r"c:\Folder-Oana\extracted"
- folder_b = r"c:\Folder-Oana\extracted\translated"
- # Define a function to get a list of all files, including subfolders
- def get_all_files(folder):
- # Initialize an empty list to store the file paths
- all_files = []
- # Use the os.walk function to walk through the directory tree
- for root, dirs, files in os.walk(folder):
- # Loop through the files in the current directory
- for file in files:
- # Append the file path to the all_files list
- all_files.append(os.path.join(root, file))
- # Return the list of file paths
- return all_files
- # Get the lists of all files in folder_a and folder_b
- files_in_folder_a = get_all_files(folder_a)
- files_in_folder_b = get_all_files(folder_b)
- # Convert the lists to sets for faster comparison
- set_a = set(files_in_folder_a)
- set_b = set(files_in_folder_b)
- # Find the files that are in folder_a but not in folder_b
- not_in_b = set_a - set_b
- # Print the filenames that are not in folder_b
- print("The following files are in folder A but not in folder B:")
- for file in not_in_b:
- print(file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement