Advertisement
nicuf

cristian

Jan 5th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import os
  2.  
  3. # Set the paths to the folders you want to compare
  4. folder_a = r"c:\Folder-Oana\extracted"
  5. folder_b = r"c:\Folder-Oana\extracted\translated"
  6.  
  7. # Define a function to get a list of all files, including subfolders
  8. def get_all_files(folder):
  9. # Initialize an empty list to store the file paths
  10. all_files = []
  11.  
  12. # Use the os.walk function to walk through the directory tree
  13. for root, dirs, files in os.walk(folder):
  14. # Loop through the files in the current directory
  15. for file in files:
  16. # Append the file path to the all_files list
  17. all_files.append(os.path.join(root, file))
  18.  
  19. # Return the list of file paths
  20. return all_files
  21.  
  22. # Get the lists of all files in folder_a and folder_b
  23. files_in_folder_a = get_all_files(folder_a)
  24. files_in_folder_b = get_all_files(folder_b)
  25.  
  26. # Convert the lists to sets for faster comparison
  27. set_a = set(files_in_folder_a)
  28. set_b = set(files_in_folder_b)
  29.  
  30. # Find the files that are in folder_a but not in folder_b
  31. not_in_b = set_a - set_b
  32.  
  33. # Print the filenames that are not in folder_b
  34. print("The following files are in folder A but not in folder B:")
  35. for file in not_in_b:
  36. print(file)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement