Re.'Compressing folders in Windows using Python'

S

sri2097

Hi all,This is in reply to the 'Compressing folders in Windows using
Python' query I raised y'day.

I figured out that windows does not allow command line zipping so I
started looking for alternatives.

I found some modules in Perl which does zipping. I guess it goes by the
name 'gzip'. I plan to write the zipping feature in Perl and import it
into Python.

Thanx a lot for all those who took time to answer my query. If you find
any loophole in the above approach feel free to drop me mail...

Srikar
 
P

Peter Hansen

sri2097 said:
Hi all,This is in reply to the 'Compressing folders in Windows using
Python' query I raised y'day.

I figured out that windows does not allow command line zipping so I
started looking for alternatives.

I found some modules in Perl which does zipping. I guess it goes by the
name 'gzip'. I plan to write the zipping feature in Perl and import it
into Python.

Cool! When you're done, check out
http://docs.python.org/lib/module-gzip.html and see how yours compares
with the standard one... ;-)

-Peter
 
T

Tim N. van der Leeuw

Isn't it much easier to figure out how python built-in module 'zipfile'
works?

Pseudo-code would be something like:

#UNTESTED
import zipfile
import os
import os.path

zf = zipfile.ZipFile('myzipfilename.zip', 'w', zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk('compressthisdir'):
for f in riles:
fullname = os.join(root, f)
zf.write(fullname)
zf.close()


Cheers,

--Tim
 
T

Tim N. van der Leeuw

Using gzip means you can compress only 1 file per gzip; so you'll have
to invent something like tar to put all your files in your directories
together into 1 file and then apply gzip on that file to get it
compressed...

Using the zipfile module should allow you to create a standard
winzip-compatible archive that puts all files directly into 1
compressed archive.

cheers,

--Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top