473,560 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ).


Jul 18 '05 #1
1 1529
<ia*******@hotm ail.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(directo ry + ".zip", "w")

for path, dirs, files in os.walk(directo ry):
for file in files:
file = os.path.join(pa th, file)
print file, "..."

print "done"

tweak as necessary.

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


Jul 18 '05 #2

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

Similar topics

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 *.doc.1, the new line characters("\r\n") are lost and the *.doc.1 document is instead displaying a null square space. I am using Log4Net to log the...
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 restarts and all active sessions are terminated. This error is also described in detail here:...
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 compiled, is there an easy way to find out how db2uext2 is configured in this regard? Many thanks.
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 widely used tool for archiving? Any info in this matter would be highly appreciated.
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 following two tables tblCustomers and tblOrders. I want to archive all orders over two years old. Is this how it is done?:
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 consumes an external web service. It has passed a userid and password to a web proxy object to pass through our corporate proxy server and has...
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 'archive' is the file name for the archive with a full path """ import zipfile, os def makeArchive(fileList, archive):
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 /path/NODE0000 and the db2 logs go there. But when I use restore db...logpath /path, the logpath in db cfg of the target database is /path. The NODE0000 is...
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 behavior when it comes to the Release varsion when I renamed its project directory name it was in! I tracked the problem down to it being the NAME of...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.