Skip to content

Instantly share code, notes, and snippets.

@oryband
Last active October 12, 2015 17:38
Show Gist options
  • Save oryband/4063135 to your computer and use it in GitHub Desktop.
Save oryband/4063135 to your computer and use it in GitHub Desktop.
Removes lower resolution duplicate wallpapers downloaded from InterfaceLift.
#!/usr/bin/env python
# encoding: utf8
"""Removes lower resolution duplicate wallpapers downloaded from
InterfaceLift.
"""
import os, re
if __name__ == '__main__':
p = re.compile(r'(.*)3840x2400.jpg') # Catch all highest resolution
home_dir = os.path.expanduser(r'~')
for f in os.listdir(r'%s/Desktop/interfacelift/' % home_dir):
result = p.match(f) # Check if file is of desired resolution.
if result: # If so, remove its lower resolution duplicate.
to_remove = (r'%s/Desktop/interfacelift/%s2880x1800.jpg'
% (home_dir, result.group(1)))
if os.path.exists(to_remove):
print 'Removing duplicate: ', os.path.basename(to_remove)
os.remove(to_remove) # Comment this line to do a dry-run:
# That is, just print the duplicates, don't really delete them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment