解压文件夹中的压缩文件 Python脚本
2009-12-23 19:28
706 查看
下载了很多压缩文件,就写了一个脚本
在Python中使用winrar命令,所以一般压缩文件都支持
有些压缩文件Python中还没有相应的库
你得先把winrar添加到path环境变量中
把代码保存为rar.py
在dos下使用,如:rar.py "D:/A B/C" mkdir
在Python中使用winrar命令,所以一般压缩文件都支持
有些压缩文件Python中还没有相应的库
你得先把winrar添加到path环境变量中
把代码保存为rar.py
在dos下使用,如:rar.py "D:/A B/C" mkdir
#rar.py #decompress with winrar #arguments :filename directory opt # opt='mkdir' to create directory with the correspond filename # opt='direct' to decompress rar files in current directory # opt='mk&del' to mkdir and delete rar file import os import sys if len(sys.argv)!=3: print ('wrong arguments/n') print ('rar.py directory opt/n') print ('opt=/'mkdir/' to create directory with the correspond filename/n') print ('opt=/'direct/' to decompress rar files in current directory/n') print ('opt=/'mk&del/' to mkdir and delete rar file/n') exit(0) #-ibck ,minimized when running opt=sys.argv[2] os.chdir(sys.argv[1]) for file in os.listdir('.'): if os.path.isfile(file) and os.path.splitext(file)[1]=='.rar': if opt=='mkdir': cmd='winrar x -ibck "'+file+'"'+' "'+os.path.splitext(file)[0]+'"//' os.system(cmd) elif opt=='direct': cmd='winrar x -ibck "'+file+'"' os.system(cmd) elif opt=='mkdel': cmd='winrar x -ibck "'+file+'"'+' "'+os.path.splitext(file)[0]+'"//' os.system(cmd) os.remove(file) else : print('wrong option')
相关文章推荐
- 自动解压大量压缩文件 Python 脚本
- Windows系统下Python压缩和解压文件、文件夹操作
- 手机中的Zip格式文件解压和文件夹的压缩
- 续写vim,shell脚本基础编辑,read命令,if与case判断语句,文件查找方式,压缩与解压,
- 利用python中的gzip模块压缩和解压数据流和文件
- Python下使用tarfile模块来实现文件归档压缩与解压
- Python脚本- 递归遍历文件夹,获取指定扩展名文件,修改文件内容
- 【Python】使用Python压缩文件/文件夹
- 解压assets资源文件夹的压缩文件,并下载到SD卡中。
- ASP.NET上传文件或文件夹并进行压缩及解压
- C#/ASP.NET/WinForm 通过ICSharpCode.SharpZipLib.dll实现文件夹、文件的压缩与解压
- 【VB.NET】利用SharpZipLib压缩与解压文件夹中的所有文件、内存中动态压缩解压数据、内存中压缩与解压文本
- Python压缩指定文件及文件夹为zip
- 跨平台的zip文件压缩处理,支持压缩解压文件夹
- python 删除文件及文件夹下的文件夹脚本(自己加个定时修改个路径ok)
- Python 实现一个小功能: 删除某路径下文件及文件夹的脚本
- python使用7z解压软件备份文件脚本分享
- python的tarfile模块实例 python把文件夹压缩成tar格式文件的例子
- shell脚本中if与case使用,查找文件locate与find的使用,压缩,解压及归档工具
- python 脚本(获取指定文件夹、指定文件格式、的代码行数、注释行数)