Skip to content

Instantly share code, notes, and snippets.

@ruofeidu
Created December 26, 2017 17:14
Show Gist options
  • Save ruofeidu/0281601aa09a8c692edddb8e73587ebc to your computer and use it in GitHub Desktop.
Save ruofeidu/0281601aa09a8c692edddb8e73587ebc to your computer and use it in GitHub Desktop.
import glob, os
dir_path = os.path.dirname(os.path.realpath(__file__))
print(dir_path)
sub_dir_list = glob.glob(dir_path + '\\test2\\*')
for dir_item in sub_dir_list:
print(dir_item)
sub_list = glob.glob(dir_item + '\\*')
for item in sub_list:
l = glob.glob(item + "\\*")
files = glob.glob(item + '\\*')
for f in files:
z1 = f.find("_log")
z2 = f.find("_urls")
if z1 > 0 or z2 > 0:
os.remove(f)
continue
q = f.rfind("\\")
p = f.rfind(".")
if p < 0 or q < 0:
continue
try:
id = int(f[q+7:p])
if id <= 50:
os.remove(f)
pass
except Exception as e:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment