[Tutor] Not storing the PATH in ZipFile?

Kent Johnson kent37 at tds.net
Wed Oct 14 18:16:04 CEST 2009


On Wed, Oct 14, 2009 at 11:38 AM, Nick Hird <nrhird at gmail.com> wrote:
> I was reading another thread and decided to work on a little project
> to backup some files on a regular basis. Since this will mostly be on
> windows i am using zipfile and i can create my zip file just fine and
> all the files are there, it works great! My question is however, is
> there a way to NOT store the path in the zip file? When i decompress
> the files, i would like them to not be associated with a particular
> folder or path, just the files

ZipFile.write() takes an optional arcname parameter, this is the name
the file wll have in the archive. If you pass the plain file name (no
path components) as arcname I think it will do what you want.

Kent


More information about the Tutor mailing list