[Tutor] writing sample program that zips files and saves in a backup directory

Kent Johnson kent37 at tds.net
Tue Oct 13 22:02:31 CEST 2009


On Tue, Oct 13, 2009 at 2:58 PM, David Eric <ciik13 at gmail.com> wrote:
> printing the command line,
> would it be
>  print('gzip {0} {1}'.format(target, ' '.join(source))?

Yes, or just
  print zip_command

> and as far as using the tar command,
> i have three files,
> file1,file2,file3
> i wanted to preserve that structure, doesnt tar combine everything into one
> file?

Yes, tar makes a single file. Do you want to preserve the individual
files? Why did you have the .gz argument in your command line? Is that
supposed to be a directory name or a file name?

My understanding of the man page is that gzip *replaces* files with
their gzipped version, so I guess if you want to back up a directory
to gzipped files you would have to first copy the directory, then
gzip.

BTW you might like to look at the zipfile module as an alternative to gzip.

Kent

PS Please Reply All to reply to the list.


More information about the Tutor mailing list