Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bulk_rename_crdownload.py
- import os
- import tkinter
- from tkinter import filedialog
- root = tkinter.Tk()
- root.withdraw() # Hide the root window
- folder = filedialog.askdirectory(parent=root, title="Choose a folder")
- files = os.listdir(folder)
- for file in files:
- try:
- if file.endswith(".crdownload"):
- new_file = file.replace(".crdownload", "")
- os.rename(os.path.join(folder, file), os.path.join(folder, new_file))
- print(f"Renamed {file} to {new_file}")
- elif '.' in file:
- new_file = file+".crdownload"
- os.rename(os.path.join(folder, file), os.path.join(folder, new_file))
- print(f"Renamed {file} to {new_file}")
- except:
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement