473,386 Members | 1,673 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,386 software developers and data experts.

Archiving directory without external tools?

Does Python have any internal facility for creating recursive archives
of a directory? I'd like to avoid reliance on extenal tools
(winzip,tar,etc).

Thanks!

Jul 18 '05 #1
1 1522
<ia*******@hotmail.com> wrote:
Does Python have any internal facility for creating recursive archives
of a directory? I'd like to avoid reliance on extenal tools
(winzip,tar,etc).


import os, sys, zipfile

directory = sys.argv[1]

zip = zipfile. ZipFile(directory + ".zip", "w")

for path, dirs, files in os.walk(directory):
for file in files:
file = os.path.join(path, file)
print file, "..."
zip.write(file)

print "done"

tweak as necessary.

(did you even look in the library reference, btw?)

</F>

Jul 18 '05 #2

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

Similar topics

5
by: SunSmile | last post by:
Hi, I am logging my exceptions to a word document(*.doc). After the size of word document is 5KB. I am archiving the word document to *.doc.1 Here when I am archiving the word document to...
6
by: Martin Bischoff | last post by:
Hi, I'm creating temporary directories in my web app (e.g. ~/data/temp/temp123) to allow users to upload files. When I later delete these directories (from the code behind), the application...
5
by: pike | last post by:
Hi Single partition DB2v8.1 FP7 on AIX 5.2. I'm trying to determine whether we're archiving logs directly to tape (and not to disk) using TSM. Without knowing from which sample it was...
1
by: sandip | last post by:
Hi All, Can someone please help me with good and easy-to-use data archiving tools for DB2 database? Does anyone have previous experience with IBM DB2 Data Archive Expert tool? Is this a...
4
by: Paul H | last post by:
Could some one give me some pointers on basic archiving techniques? I have developed several databases but never been faced with this issue. Here is the basic scenario.. Suppose I have the...
0
by: J Ames | last post by:
Please, if this is the incorrect forum for this question, let me know which forum is most appropriate. I want to make sure I get visibility with the proper gurus! I have a .NET console app that...
3
bvdet
by: bvdet | last post by:
Following is an example that may provide a solution to you: """ Function makeArchive is a wrapper for the Python class zipfile.ZipFile 'fileList' is a list of file names - full path each name...
2
by: saramathi | last post by:
I am trying to understand the logging and archiving features of DB2 V8.2 And I have a couple of questions: 1. When I issue update db cfg using newlogpath /path, the logpath in db cfg is...
28
by: Peter Oliphant | last post by:
I have written a program using MS VS VC++ 2005 Express, /cli pure. Upon compiling it it works fine in the GUI development environment. It also works fine as a Debug stand-alone. ut I had an odd...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.