Skip to content

Instantly share code, notes, and snippets.

@Lubba-64
Created March 22, 2022 17:06
Show Gist options
  • Save Lubba-64/64b594c3c38c52e5c25c95866ca9ec26 to your computer and use it in GitHub Desktop.
Save Lubba-64/64b594c3c38c52e5c25c95866ca9ec26 to your computer and use it in GitHub Desktop.
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!')
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!')
@Lubba-64
Copy link
Author

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.py to basically extract all the files so the messy directory structure is not present.
I used remove_all_underscored.py to remove all metadata files, which weren't photos or videos, just some weird stuff iphoto stores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment