ZipFile.write has a second parameter,
arcname, which allows you to rename files without any copying. You don’t need to move
file to a separate folder, or actually rename it.
from os.path import basename for file in filenames_list: if (name := get_friendly_name(file)) is None: name = basename(file) zipF.write(file, name, compress_type=zipfile.ZIP_DEFLATED)
By stripping off the
basename, you avoid the need to move to a common folder at all.
CLICK HERE to find out more related problems solutions.