pretend to have done:oday 压缩文件解压工具------python版 - 独木的日志 - 网易博客
来源:百度文库 编辑:偶看新闻 时间:2024/04/29 10:58:55
oday 压缩文件解压工具------python版
python 2007-04-04 14:03:39 阅读76 评论0 字号:大中小 订阅
原来使用batch来调用WinRAR,解压oday 压缩文件,总是有些问题。后来学习python,就将程序改了一下,修正一些bug。#!/usr/bin/python
# -*- coding: UTF-8 -*-
# demo of the usage of python
#
#
#
"""Test code
Suggested usage: import MyUnrar
"""
__decription__ = "Batch Unrar Kit"
__version__ = "0.1"
__date__ = " Mar.28th.2007"
__author__ = "hu
__license__ = "Licensed under the GPLv2, see the file LICENSE in this tarball."
__copyright__= "Copyright (C) 2007 by hu
from time import sleep
import string
import os
from os.path import join, getsize, abspath, exists, splitext
__WinRAR__="C:\\Program Files\\WinRAR\\WinRAR.exe"
exec_rar= '\"'+__WinRAR__ + '\"'
urar_chm =""" IF EXIST *.rar """ + exec_rar +""" e -o- -y *.rar *.chm """
urar_pdf = """IF EXIST *.rar """ + exec_rar + """ e -o- -y *.rar *.pdf"""
class MyUnrar:
###
def __init__ (self, path=os.getcwd()):
self.path = path
self.count = 0
###
def checkRAR(self):
if exists(__WinRAR__):
print "WinRAR is OK!"
else:
print "WinRAR is not there!"
###
def unrar(self):
print self.count
for f in os.listdir( self.path ) :
(filename, ext) = splitext(f)
if ext.lower() == ".zip":
command =exec_rar + ' e -o- -y ' + f + ' *.r*'
os.system( command )
if ext.lower() == ".rar":
os.system( urar_chm )
os.system( urar_pdf )
self.count = self.count + 1
def unrar(self, path):
print self.count
for f in os.listdir( path ) :
(filename, ext) = splitext(f)
if ext.lower() == ".zip":
command =exec_rar +' e -o- -y ' + path + '\\' + f + ' *.r*'
# print command
os.system( command )
if ext.lower() == ".rar":
os.system( urar_chm )
os.system( urar_pdf )
self.count = self.count + 1
def deleteRAR(self):
for f in os.listdir( self.path ) :
(filename, ext) = splitext(f)
if ext.lower().find(".r") != -1:
os.remove(f)
###
def run(self):
print "==============================="
print __decription__
print 'version:', __version__
print __license__
print __copyright__
print "==============================="
self.checkRAR();
for root, dirs, files in os.walk( self.path ):
for name in dirs:
fullpath = join(root, name)
print fullpath
self.unrar(fullpath)
os.system( urar_chm )
os.system( urar_pdf )
self.deleteRAR()
###
if __name__=="__main__":
ur = MyUnrar()
ur.run()
sleep(5)
exe压缩文件可以解压吗?用什么工具啊,急用...
我有一个很大的解压缩文件,一般的解压工具解压不了,请问用什么工具才能解压这种比较大的压缩文件?
压缩文件怎样解压?
如何解压压缩文件?
如何把压缩文件解压?
如何解压photoshop压缩文件
关于压缩文件的解压
压缩文件怎么解压?
压缩文件解压后打不开?
压缩文件解压后大不开?
怎么解压ZIP压缩文件
怎样把压缩文件解压
压缩文件不能解压!!
压缩文件不能解压!!
压缩文件一起解压问题
压缩文件要解压到哪去?
如何解压RAR压缩文件
压缩文件不能解压怎么办!
压缩文件的图标全变为还没有安装解压工具WINRAR时的图标,怎么变回来?
解压工具
RAR压缩文件解压出错问题,
压缩文件无法解压的问题
有谁知道如何解压压缩文件?
怎么解压RAR的压缩文件