473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Re.'Compressing folders in Windows using Python'

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

Jan 2 '06 #1
4 1694
sri2097 wrote:
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

Jan 2 '06 #2
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

Jan 2 '06 #4
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

Jan 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bob | last post by:
Hi, I'm new to Python and I want to create a script that will import contactitems into an Outlook Public Folder. Therefore I've installed the Python for Windows Extensions. This way I can...
6
by: sri2097 | last post by:
Hi, I'm trying to zip a particular fiolder and place the zipped folder into a target folder using python. I have used the following command in 'ubuntu'. zip_command = 'zip -qr %s %s' % (target,...
3
by: msankardas | last post by:
Hi, As a part of my project, i need to compress folders and files into a single zip file as follows. for eg: I want to compress C:\test\ c:\compression\ C:\documents\test.txt
2
by: bearophileHUGS | last post by:
Helmut Jarausch: Asking in comp.compression is a good starting point. My suggestions (sorry if they look a bit unsorted): it depends on what language you want to use, how much you want to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.