fs – Files, Directories, &c.


The fs module makes it easy to work with files, directories, drives, volumes and paths within the Windows filesystems. The most common entry-point is to use entry() to return a File or Dir object, although you can use file() or dir() directly. Instances of these classes need not exist on any filesystem – in fact they equate to True or False according to the existence or not of a corresponding filesystem object. But they can be the source or target of all the usual filesystem operations. In common with other modules in this package, functionality is provided at the module level as well as at the class level, so you can, eg, call File.copy() or copy() to copy a file to another location.

An important part of the module is the FilePath class which eases manipulation of filesystem paths and is at the same time a subclass of unicode, so is accepted in system calls where strings are expected.



stdlib Extras

Several functions are either convenient or superior replacements to equivalent stdlib functionality.


Additional Filesystem Operations




See also

Using the fs module
Cookbook examples of using the fs module