def get_dir(start_path):
names = os.listdir(start_path)
for name in names:
in_path = start_path + os.sep + name
wash_data(in_path)
if os.path.isdir(in_path):
get_dir(in_path)
将带有广告的文件全部重命名
def wash_data(path):
if "【" in path:
start = path.split("【")[0]
end = path.split("【")[1].split("】")[1]
res = start + end
save_data(res)
os.rename(path, res)
else:
save_data(path)
def write_data(all_path):
result = "\n".join(all_path) # os.linesep
with open("FileName.txt", "a", encoding="utf-8") as f:
print(result)
f.write(result)