python呼叫7zip命令實現檔案批量解壓
1.輸入壓縮檔案所在的路徑
2.可以在**中修改解壓到的檔案路徑和所需要解壓的型別,列入,解壓資料夾下面所有的mp4格式的檔案
3.cmd 指的就是python呼叫dos命令 ,緊跟著的x -r這些全是參考7zip使用書冊,及抽取資料夾下所有的以mp4結尾的檔案,把檔案放入e盤,測試解壓資料夾下的new資料夾
#呼叫7z命令批量解壓檔案
import
osfolder_name = input("
請輸入資料夾:")
os.chdir(folder_name)
file_names = os.listdir("./"
)for name in
file_names:
print("
是不是檔案:
", os.path.isfile(name))
ifos.path.isfile(name):
name =os.path.abspath(name)
#返回乙個元組,元組第二個元素是副檔名
if os.path.splitext(name)[1] == "
.zip":
cmd = '
\"c:\\program files\\7-zip\\7z.exe\" x \"\" -oe:/測試解壓/new *.mp4 -r
'.format(name)
os.popen(cmd)
7zip命令列工具
壓縮zip檔案 7z a 壓縮檔案 源資料夾 7z a helpdoc.zip helpdoc 壓縮helpdoc目錄 7z a helpdoc.zip 壓縮當前目錄下的檔案 壓縮zip檔案,新增指定目錄及檔案 7z a html.zip aspx i bin dll i css i images ...
命令列使用7zip
現在大家都用winrar,不知道聽說過7zip的朋友多不多。7zip是乙個開源的壓縮軟體,非常小巧,提供的功能和winrar差不多,但支援的格式幾乎比後者多一倍。根據我的使用經驗,其7z壓縮格式的壓縮速度及壓縮比也領先於winrar winrar亦可識別7z格式,故不必擔心相容性問題 另一點重要的是...
CentOS 安裝7 Zip 以及解壓命令
在shh或者終端下輸入 yum y install p7zip wget tar xjvf p7zip 4.65 src all.tar.bz2 cd p7zip 4.65 make make install 看到如下資訊就說明你安裝成功了 install.sh usr local bin usr ...