Skip to content

Instantly share code, notes, and snippets.

@montycheese
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montycheese/defccf97d055674dfce9 to your computer and use it in GitHub Desktop.
Save montycheese/defccf97d055674dfce9 to your computer and use it in GitHub Desktop.
Delete files with multiple versions
import os, glob
path = "/Users/mowong/Documents/Thumbnails/Big_Thumbnail_Project" # update to current dir
list = ["1","3","4"] #append here the version number(s)
for x in list:
for files in glob.glob("/Users/mowong/Documents/Thumbnails/Big_Thumbnail_Project/*-0%s.jpg" % x):
os.remove(files)
import os, glob, shutil
# src1 = "/Users/mowong/Documents/Thumbnails/Big_Thumbnail_Project"
dst = "/Users/mowong/Desktop/Trashed_thumbs"
list = ["01", "03", "04", "06", "07", "08","09", "10", "11", "12", "13"]
for x in list:
for files in glob.glob("/Users/mowong/Documents/Thumbnails/JJsprojectThumbs/*-%s.jpg" % x):
shutil.move(files, dst ) #moves extras to new dir.
import os, glob, shutil
dst = "/Users/mowong/Desktop/Trashed_thumbs"
list = ["16","17","18","19","20","21","22",
"23","24","25", "26","27","28","29",
"30","31","32","33","34","35","36","37",
"38","39","40"
]
for x in list:
for files in glob.glob("/Users/mowong/Documents/Thumbs_exported/400x300/samjack/mas/*_0%s.jpg" % x):
os.mkdir("/Users/mowong/Documents/Thumbs_exported/400x300/samjack/mas/0%s" % x)
shutil.move(files, "/Users/mowong/Documents/Thumbs_exported/400x300/samjack/mas/0%s" % x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment