Last active
December 29, 2015 21:05
-
-
Save alexras/9c907cd25b2c1acf2ba4 to your computer and use it in GitHub Desktop.
Find all files with a resource fork that begin with the magic number 'DDA2'; these are DiskDoubler archives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import os | |
| import subprocess | |
| DIRS_TO_SKIP = ['.fseventsd', '.Spotlight-V100'] | |
| for (dirpath, dirnames, filenames) in os.walk(os.getcwd()): | |
| should_skip = False | |
| for dir_to_skip in DIRS_TO_SKIP: | |
| if dir_to_skip in dirpath: | |
| should_skip = True | |
| break | |
| if should_skip: | |
| continue | |
| file_paths = (os.path.join(dirpath, filename) for filename in filenames) | |
| for file_path in file_paths: | |
| try: | |
| xattrs = filter(lambda x: len(x) > 0, subprocess.check_output( | |
| ['/usr/bin/xattr', file_path]).strip().split('\n')) | |
| if 'com.apple.ResourceFork' in xattrs: | |
| with open(file_path, 'rb') as fp: | |
| if str(fp.read(4)) == 'DDA2': | |
| print file_path | |
| except subprocess.CalledProcessError: | |
| continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment