dirutility is a Python package for generating an inventory of files within a directory tree.
Often we encounter directories with vast file structures too large to sort through by manually. Directory Utilities allows users to create inventories of files and manipulated data structures._
Directory Utilities is built using almost entirely builtin Python libraries making it extremely lightweight. The walk module performs 'inventory' tasks that return information on file and folder contents of a root directory. The move module performs 'structure' tasks that reorganize the data structures within a directory based on a variety of parameters.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Upgrade to the latest version of pip
pip install --upgrade pip
Create a virtual development environment and install the latest version of dirutility from PyPi or github
PyPi distribution
pip install dirutility
GitHub distribution
pip install git+git://github.com/sfneal/dirutility.git
or
pip install git+https://github.com/sfneal/dirutility.git
Outlined below are basic uses of the four main classes of the directory utility python package.
- DirPaths - Retrieve a list of paths within a root directory
- DirTree - Retrive a nested dictionary representing a roots file structure
- FlattenTree - Flattens the contents of a root directory by moviing all sub-folders and files to root
- CreateTree - Create organized file structure based on indexing of files within root
This class generates a list of either files and or folders within a root directory. The walk method generates a directory list of files by walking the file tree top down or bottom up. The files and folders method generate a list of files or folders in the top level of the tree.
Generate list of all file paths within a directory.
Generate file paths list and exclude particular files.
Generate file paths list with concatenated full paths.
# Root directory
root = '/Volumes/Storage/test'
dirs = DirPaths(root, to_include=['.psd', '.png'], to_exclude=['.dwg'])
- looptools - Logging output, timing processes and counting iterations.
- tqdm - A fast, extensible progress bar for Python
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Stephen Neal - Initial work - StephenNeal
This project is licensed under the MIT License - see the LICENSE.md file for details