File system object manipulation (learner)

Remco Gerlich scarblac at pino.selwerd.nl
Wed May 16 09:23:00 EDT 2001


Scott Finnie <scott at projtech.com> wrote in comp.lang.python:
> Hi,
> 
> I'm looking to write some fairly noddy tools for synchronising files
> between two systems - as much as a learning exercise as anything else.
> 
> The Python core libs support file operations, but they deal with file
> contents; I need a higher level than that, and don't want to write a
> file copy in Python (too slow).  Shopping list as follows:
>
> . list files in directory (ideally recursively)

os.path.walk

> . copy file from one location to another

shutil.copy

> . get file stats (date, time, size, - os.* call for this exists I think)

os.stat

> . compare contents (e.g. generate MD5 checksums and compare?)

difflib, md5 modules

> . create/explode archives using standard formats (e.g. tar, (g)zip)

zlib, gzip modules

> . compress/uncompress files (would be nice).

well, gzip again, or zipfile (.zip files do archives so you don't need tar)

> I'm a bit unsure where best to turn for available modules: goals are
> ideally cross platform (win32+unix) although win32 is most important.

It's all standard library except for tar. Using .zip files instead of
.tar.gz means you don't need tar. Haven't used it myself, but it should all
be cross platform.

-- 
Remco Gerlich



More information about the Python-list mailing list