https://github.com/gjjvdburg/ffcount
Fast File and Directory Counting in Python
https://github.com/gjjvdburg/ffcount
dir-count file-count python recursive
Last synced: 8 months ago
JSON representation
Fast File and Directory Counting in Python
- Host: GitHub
- URL: https://github.com/gjjvdburg/ffcount
- Owner: GjjvdBurg
- License: apache-2.0
- Created: 2018-03-23T21:12:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-09T21:52:27.000Z (over 2 years ago)
- Last Synced: 2024-10-14T12:37:16.852Z (over 1 year ago)
- Topics: dir-count, file-count, python, recursive
- Language: Python
- Homepage:
- Size: 82 KB
- Stars: 10
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Fast File Count in Python
[](https://github.com/GjjvdBurg/ffcount/actions?query=workflow%3Abuild)
[](https://pypi.org/project/ffcount)
[](https://pepy.tech/project/ffcount)
This is a Python package to quickly count the number of files and directories
in a given path. Optionally you can count recursively and include hidden files
in the total.
This package is a wrapper around ``fast-file-count`` by [Christopher Schultz
](https://github.com/ChristopherSchultz). Credit for the initial version
belongs to Christopher Schultz, I wrote the Python wrapper, converted the
Windows code to use builtin functionality, and packaged it up. See the file
``src/c_count.c`` for the other contributors and see the commit history of
this package on GitHub for my exact changes.
## Installation
Installation can be done easily with pip:
```bash
$ pip install ffcount
```
## Usage
There is a command line application called ``ffcount``, which recursively
counts files and directories:
```
$ ffcount
```
See ``ffcount -h`` for options.
The package can also be used as a Python library, using the ``ffcount``
function. This function returns a tuple ``(number_of_files, number_of_dirs)``
and it can be used as follows:
```python
>>> from ffcount import ffcount
# count everything under the current path
>>> ffcount()
(521013, 43012)
# count without hidden files
>>> ffcount(hidden=False)
(234012, 12082)
# use a different path
>>> ffcount('/tmp')
(81, 10)
```
Note that ``ffcount`` counts links as files, even if they point to a
directory. In some cases, this explains the discrepancy with other ways of
counting.
To obtain the full function documentation, simply run:
```python
>>> import ffcount
>>> help(ffcount)
```
## License
The original C code by Christopher Schultz was licensed under the Apache
License 2.0. This package is therefore licensed under this license as well.