Browse Source

上传文件至 /

main
Fiber 9 months ago
commit
8cef5e0db0
  1. 47
      copy.py

47
copy.py

@ -0,0 +1,47 @@
import os
import sys
import re
import shutil
import time
download_dir = "/downloads/Default"
save_dir = "/downloads/Anime"
def delete(path):
f = list(os.listdir(path))
for i in range(len(f)):
date = os.path.getmtime(os.path.join(path,f[i]))
currdate = time.time()
num1 =(currdate - date)/60/60/24
if num1 >= 1:
try:
os.remove(path + f[i])
except Exception as e:
print(e)
name = sys.argv[1]
save_name = name
name_title = name.split(".")[0]
name_re = re.match("(.*) - \d\d (.*)",name_title)
if name_re:
sub_name = name_re.group(1) + " " + name_re.group(2)
else:
name_re = re.match("(.*) \[(\d\d)\](.*)", name_title)
if name_re:
sub_name = name_re.group(1) + " " + name_re.group(3)
save_name = name.replace(" [{}]".format(name_re.group(2)), " - {} ".format(name_re.group(2)))
sub_save_dir = os.path.join(save_dir, sub_name)
if not os.path.exists(sub_save_dir):
os.makedirs(sub_save_dir)
os.chmod(sub_save_dir, 511)
shutil.copyfile(os.path.join(download_dir, name), os.path.join(sub_save_dir, save_name))
os.chmod(os.path.join(sub_save_dir, save_name), 511)
#delete(download_dir)
Loading…
Cancel
Save