Created
March 22, 2022 17:06
-
-
Save Lubba-64/64b594c3c38c52e5c25c95866ca9ec26 to your computer and use it in GitHub Desktop.
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
| import os | |
| import shutil | |
| to_clean = './compressed' | |
| output = './full_cleaned' | |
| if not os.path.exists(output): | |
| os.makedirs(output) | |
| def clean(dir:str): | |
| children = [f'{dir}/{child}' for child in os.listdir(dir)] | |
| files = [child for child in children if os.path.isfile(child)] | |
| for file in files: | |
| file_base = os.path.basename(file) | |
| print(file_base, ) | |
| if file_base.startswith('IMG_'): | |
| shutil.copy(file,f'{output}/{file_base}') | |
| print(f'copy:{file_base}') | |
| clean(to_clean) | |
| print('done!') |
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
| import os | |
| import shutil | |
| output = './compressed' | |
| if not os.path.exists(output): | |
| os.makedirs(output) | |
| to_clean = './Masters' | |
| current_root = '' | |
| def clean(dir:str): | |
| children = [f'{dir}/{child}' for child in os.listdir(dir)] | |
| folders = [child for child in children if os.path.isdir(child)] | |
| files = [child for child in children if os.path.isfile(child)] | |
| for folder in folders: | |
| clean(folder) | |
| for file in files: | |
| file_base = os.path.basename(file) | |
| shutil.copy(file,f'{output}/{file_base}') | |
| print(f'copy:{file_base}') | |
| clean(to_clean) | |
| print('done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a bunch of old pictures from an ancient IMAC I recovered, that I wanted to remove all extraneous folders and metadata files and BS that makes it harder to browse the raw files. this is because I copied them from iphoto which stores the photos pretty weird.
I used
remove_extra_folders.pyto basically extract all the files so the messy directory structure is not present.I used
remove_all_underscored.pyto remove all metadata files, which weren't photos or videos, just some weird stuff iphoto stores.