[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 ".