demo.py mainly acts as
Rename the *.mp4 file batch under the same catalogue
For example:
aaa001.mp4---renamed --001.mp4
aaa002.mp4 ---renamed --002.mp4
#!/usr/local/bin/python#-*-coding:utf-8-*- fromTkinterImport*Importsys,glob,osreload (SYS) sys.setdefaultencoding ("Utf-8")classHelloApp (Frame):def __init__(Self, master=None): Frame.__init__(self, Master) Self.grid () self.createwidgets () Self.count=0defcreatewidgets (self): self. QUIT=Button (self) self. quit["text"] ="QUIT"Self . quit["Command"] =self.quit Self. Quit.grid (Row=0, column=0) Self.hi=Button (self) self.hi["text"] ="RUN"self.hi["Command"] =self.run self.hi.grid (Row=0, Column=1) Self.text=Label (self) self.text["text"] =""Self.text.grid (Row=1, column=0,columnspan=2) defRun (self): Allfiles= Glob.glob (r'.. /.. /.. /*.mp4') #allfiles = Glob.glob (R ' *.mp4 ')self.text["text"] ='Execute Start'ListName="' forAfileinchAllfiles:listname=listname +","+afile New_filename= Afile.replace ('AAA',"")#Print Afileos.rename (Afile, new_filename) self.text["text"] ='Execute Complete'+ListNameif __name__=='__main__': Root=Tk () root.wm_title ("IMOOC Rename Tool") #root.maxsize (+)Root.geometry ('400x300') #root.resizable (width=true, height=true)App = HelloApp (master=root) app.mainloop ()
>Py2applet--Make- Setup demo.py
Existing setup.py detected, replace? [y/N] y
Wrote setup.py
>ls
Aaa001.mp4 aaa002.mp4 demo.py setup.py
> python setup.py py2app
.
.
.
Done!
>ls
Aaa001.mp4 aaa002.mp4 build demo.py Dist setup.py
>ls./Dist
Demo.app
>ls
aaa001. mp4 AAA002. mp4 Build demo.py Dist setup.py
> CP -R./dist/demo.app./
>ls
Aaa001.mp4 aaa002.mp4 build demo.app demo.py Dist setup.py
Execute demo.app.
Click the Run button to rename the batch.
[Records renamed with]python Py2app file batch