Today, when I was sorting out computer files, I found a folder in f disk with many repeated compressed files in RAR format. Delete manually too laborious, just get a Python program to automatically > delete a ha.
import os def del_files(path): for root, dirs, files, in os.walk(path): for name in files: if name.endswith(".rar"): os.remove(os.path.join(root, name)) print("Delete file:" + os.path.join(root, name)) if __name__ == "__main__": Path =" file path "del_files(path)Copy the code