def BulidLinkB(): import time, MyDef, os start_time = time.time() # 初始时间戳 refer_dict = ReadMD5SamplingCSV() MD5_refer_dict, MD5_list = ReadMD5CSV() yun_link_dict = ReadMobile() output_list = [] # ========================主目录======================== for key in refer_dict: if key in yun_link_dict: folder_name = MyDef.HexShift(key) yun_link = yun_link_dict[key] sample_list = refer_dict[key].split("|") print(sample_list) # ========================次级目录======================== for sample in sample_list: # 文件MD5 file_path = MD5_refer_dict[sample] file_name = os.path.split(file_path)[1] file_folder_name = MyDef.HexShift(sample) file_link = yun_link + '#path=%252F' + folder_name + '%252F' + folder_name + file_folder_name print(file_name) print(file_link) path_list = [file_path, file_link] output_list.append(path_list) path = '/Users/alicewish/Dropbox/漫画图源度盘地址表.csv' MyDef.StoreCSV(output_list, path) print(len(output_list)) print(MyDef.RunTime(start_time))
def UnDistribute(): import time, MyDef, os, shutil start_time = time.time() # 初始时间戳 refer_dict = ReadMD5SamplingCSV() MD5_refer_dict, MD5_list = ReadMD5CSV() # ========================最外层目录======================== new_file_dir = '/Volumes/Mack/Distribute' # ========================主目录======================== for key in refer_dict: folder_name = MyDef.HexShift(key) new_folder_path = os.path.join(new_file_dir, folder_name) sample_list = refer_dict[key].split("|") print(sample_list) # ========================次级目录======================== for sample in sample_list: # 文件MD5 file_path = MD5_refer_dict[sample] file_name = os.path.split(file_path)[1] print("旧", file_path) file_folder_name = MyDef.HexShift(sample) new_file_folder_path = os.path.join(new_file_dir, folder_name, folder_name + file_folder_name) new_file_path = os.path.join(new_file_folder_path, file_name) print("新", new_file_path) try: shutil.move(new_file_path, file_path) # 移动文件或目录都是使用这条命令 except: pass print(MyDef.RunTime(start_time))