Advertisement
Python253

bin_metadata

Apr 26th, 2024
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.14 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # Filename: bin_metadata.py
  4. # Version: 1.0.0
  5. # Author: Jeoi Reqi
  6.  
  7. """
  8. This script scans the recycle bin for deleted file metadata.
  9.  
  10. Requirements:
  11. - Python 3.x
  12. - Operating system supporting the $Recycle.Bin directory structure
  13.  
  14. Functions:
  15. - scan_recycle_bin(): Scans the recycle bin directory for deleted file metadata.
  16. - main(): Main function to execute the script.
  17.  
  18. Usage:
  19. 1. Ensure Python 3.x is installed on your system.
  20. 2. Run the script using the command: python bin_metadata.py
  21.  
  22. Additional Notes:
  23. - This script does not delete or edit any files, it only scans for metadata.
  24. - Elevated privileges may be required to access system directories, especially on Windows.
  25. - The script outputs the path of deleted file metadata found in the recycle bin.
  26. - Use caution when interacting with system directories to avoid unintentional modifications.
  27. """
  28.  
  29. import os
  30.  
  31. def scan_recycle_bin():
  32.     """
  33.    Scans the recycle bin directory for deleted file metadata.
  34.  
  35.    Returns:
  36.        List: A list containing the paths of deleted file metadata found in the recycle bin.
  37.    """
  38.     recycle_bin_path = os.path.join('C:', '\\$Recycle.Bin')
  39.     if not os.path.exists(recycle_bin_path):
  40.         print("\nRecycle bin directory not found!\n")
  41.         return []
  42.  
  43.     print("\nRecycle bin directory found!\n\nDeleted File Metadata Content:\n")
  44.     deleted_files = []
  45.     for root, dirs, files in os.walk(recycle_bin_path):
  46.         for file in files:
  47.             deleted_files.append(os.path.join(root, file))
  48.             print(os.path.join(root, file))
  49.         for directory in dirs:
  50.             deleted_files.append(os.path.join(root, directory))
  51.             print(os.path.join(root, directory))
  52.  
  53.     return deleted_files
  54.  
  55. def main():
  56.     """
  57.    Main function to execute the script.
  58.    """
  59.     # Scan recycle bin for deleted files
  60.     deleted_files = scan_recycle_bin()
  61.  
  62.     if deleted_files:
  63.         print(f"\nFound {len(deleted_files)} deleted file metadata in the recycle bin.\n")
  64.     else:
  65.         print("\nNo deleted file metadata found!\n")
  66.  
  67. if __name__ == "__main__":
  68.     main()
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement