Dec-01-2020, 02:46 AM
Hi, I'm trying to find files that have digits in a file name.
then I'd like to zip files to another directory.
My code finds the files I want and moves them to a directory I want but not as ZIP files
.
Any help will be appreciated.
then I'd like to zip files to another directory.
My code finds the files I want and moves them to a directory I want but not as ZIP files
.Any help will be appreciated.
from zipfile import ZipFile
import os
import glob
import os.path
pth = 'c:\\02'
zout= 'C:\\0001\\'
for fname in glob.glob('C:\\02\\*[0-9].*'):
basename = os.path.basename(fname)
fz = zout+basename
with ZipFile(fz,'w') as zip:
zip.write(fz)
