1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
from Tkinter import *
import os
import shutil
import tkFileDialog
def Rename():
for path, dirs, files in os.walk(WorkDir):
for Directorie_Name in dirs:
UpperCase_File_Name = Directorie_Name
print Directorie_Name
pathfile = os.path.join(path, Directorie_Name)
Old_Name_File= os.listdir(pathfile)[0]
pathOldFile = os.path.join(pathfile, Old_Name_File)
pathNewFile = os.path.join(pathfile, UpperCase_File_Name)
os.rename (pathOldFile, pathNewFile+'.avi')
def ChooseWorkDirectory():
WorkDir = tkFileDialog.askdirectory(parent=root, initialdir="/", title="Please select a work directory")
Ent.delete(0,END)
Ent.insert(END, WorkDir)
print WorkDir
root = Tk()
root.geometry("600x100+10+10")
root.title("Rename Movie File v1.0")
Frame_1 = Frame(root, width=400, height=100)
Frame_1.pack(side='top')
Folder = Label(Frame_1, text="Work Directory")
Folder.grid(row=0,column=0)
Ent = Entry(Frame_1, width=40)
Ent.grid(row=0,column=1, pady=10)
Select = Button(Frame_1, text='SELECT', width=10, height=1, command = ChooseWorkDirectory)
Select.grid(row=0, column=2)
Footer = Frame(root, width=400, height=100)
Footer.pack_propagate(False)
Footer.pack(side="bottom", pady=5)
Exit = Button(Footer, text='-EXIT-', width=10, height=1, command = root.destroy)
Exit.pack(side = 'left', padx=5, pady=5)
Apply = Button(Footer, text='-APPLY-', width=10, height=1, command = Rename)
Apply.pack(side = 'right', padx=5, pady=5)
root.mainloop() |
Partager