[Records renamed with]python Py2app file batch

Source: Internet
Author: User

demo.py mainly acts as

Rename the *.mp4 file batch under the same catalogue

For example:
Aaa001.mp4-001.mp4
Aaa002.mp4-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')#使用py2app打包時 Relative path changes
#allfiles = Glob.glob (R ' *.mp4 ')self.text["text"] =' start to execute.'ListName="' forAfileinchAllfiles:listname=listname +","+afile New_filename= Afile.replace ('AAA',"") #Print Afileos.rename (Afile, new_filename) self.text["text"] =' Execute done'+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.pyExisting setup.py detected, replace? [y/N] ywrote setup.py>lsaaa001.mp4 aaa002.mp4 demo.py setup.py > python setup.py py2app... Done!>lsaaa001.mp4 aaa002.mp4 build demo.py Dist setup.py>ls./DistDemo.app >ls001. mp4002. mp4 Build demo.py Dist setup.py> CP -R./dist/demo.app./>lsaaa001.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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.