Skip to content

Instantly share code, notes, and snippets.

@naoyeye
Created November 9, 2012 03:55
Show Gist options
  • Save naoyeye/4043596 to your computer and use it in GitHub Desktop.
Save naoyeye/4043596 to your computer and use it in GitHub Desktop.
import os
homedir = os.getcwd()
part_name = '201211981222_7a214d288112fe8ef99944aa7ce4d228'
path = '/static/upload/post_img/2012/11/9'
imgPath = homedir + path
if os.path.isfile(imgPath + '/.DS_Store'):
os.remove(imgPath + '/.DS_Store')
files = os.listdir(imgPath)
for file in files:
p = file.split('.')[0]
p2 = p.split('_',2)[0]
p3 = p.split('_',2)[1]
if p2+'_'+p3 == part_name:
file = imgPath + "/" + file
os.remove(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment