[Remember to use] python py2app batch rename, py2app

Source: Internet
Author: User

[Remember to use] python py2app batch rename, py2app

Demo. py mainly serves

Rename the batch of *. mp4 files under the same category

For example:
Aaa001.mp4 --- rename it --> 001.mp4
Aaa002.mp4 --- rename it --> 002.mp4

#! /Usr/local/bin/python #-*-coding: UTF-8-*-from Tkinter import * import sys, glob, osreload (sys) sys. setdefaultencoding ("UTF-8") class HelloApp (Frame): def _ init _ (self, master = None): Frame. _ init _ (self, master) self. grid () self. createWidgets () self. count = 0 def createWidgets (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) def run (self): allfiles = glob. glob (R '.. /.. /.. /*. mp4') # allfiles = glob. glob (R '*. mp4') self. text ["text"] = 'start row start 'listname = ''for afile in allfiles: listname = listname +", "+ afile new_filename = afile. replace ('aaa', "") # print afile OS. rename (afile, new_filename) self. text ["text"] = 'success row completion '+ listname if _ name _ =' _ main _ ': root = Tk () root. wm_title ("imooc rename tool") # root. maxsize (800,600) 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

Demo. app

Click "RUN" and rename it in batches by "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.