The ipad goodreader to JS file support is not very good, although can read it but always can't quit, back to the GoodReader main interface, so I need to batch JS file into plain text. For this purpose, I have made the following small application:
The code is as follows:
#-*-Coding:utf-8-*-
Import OS
def rename ():
Path = Raw_input ("Enter the folder path to process")
Print path
Old_ext = "." +raw_input ("Please enter the type of file to be processed")
Print Old_ext
New_ext = "." +raw_input ("Please enter the type of file you want to become")
Print New_ext
For (path, dirs, files) in Os.walk (path): #遍历目录树
For filename in Files:
ext = os.path.splitext (filename) [1] #取得文件类型, pay attention to it with the dot number
Print ext;
if (ext = = Old_ext):
Print "----------------"
newname = Filename.replace (Old_ext, New_ext)
OldPath = path + "\ \" + filename
NewPath = path + "\ \" + newname
Try
Os.rename (OldPath, NewPath)
Except Baseexception, E:
Print (str (e))
if __name__ = = ' __main__ ':
Rename ()