简体   繁体   中英

How to create zip archive without ini and zip files

I have a folder which contain :

bd.txt
/Config
/DLL
/Rapports
bx1478.ini
ARCH.zip

I want to create an archive without ini and zip files. I try as below but i get an empty archive :

import subprocess
SZ_PATH_TMP = '../tmp'
SZ_PATH_WORK = '../work'
full_label_version = 'ARCH' 
subprocess.call(['7z', 'a', SZ_PATH_TMP+'/'+full_label_version+'.zip', SZ_PATH_WORK+'/* -xr!*.zip -xr!*.ini'])

When you pass a list of arguments to subprocess , each option needs to be a separate list item.

import subprocess
SZ_PATH_TMP = '../tmp'
SZ_PATH_WORK = '../work'
full_label_version = 'ARCH' 
subprocess.call(
    ['7z', 'a', 
    SZ_PATH_TMP+'/'+full_label_version+'.zip',
    SZ_PATH_WORK+'/*,  '-xr!*.zip', '-xr!*.ini'])

If you don't know exactly how the shell breaks the command line up into arguments, maybe pass the entire command as a string to shlex.split()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM