5 releases
new 0.2.8 | Oct 24, 2024 |
---|---|
0.2.7 | May 3, 2024 |
0.2.6 | Feb 25, 2024 |
0.2.5 | Aug 8, 2023 |
0.2.3 | Jan 30, 2023 |
#287 in Command line utilities
139 downloads per month
28KB
686 lines
fcnt
fcnt is a file counter used in command line.
It can quickly count the number and size of huge amount of files in multiple directories through multi-threading.
Usage
$ fcnt [OPTIONS] [DIRECTORIES]...
-
Arguments:
[DIRECTORIES]... The directories (default: ./)
-
Options:
-a Count all regular and hidden files -d Count the number of directories -o <ORDER_BY> The value to sort the results. Possible values: [n]ame, [f]ile, [d]ir, [s]ize. -r <PATTERN> Match entries using regex (only matche filenames) -R Non-recursive mode (files in sub-directories will be ignored) -s Count the total size of files -t <TOP> The number of threads for traversal (invalid in `non_recursive` mode) -T <THREAD_NUM> The number of threads for traversal (invalid in `non_recursive` mode) -v Verbose mode, open this option will display the found entries -h, --help Print help (see more with '--help') -V, --version Print version
Example
By default, only the number of sub-files in each directory is included in the result.
fcnt ./Pictures ./Music ./src/package
Path Files
./src/package 8070
./Pictures 7799
./Music 3455
──────────────────────────
Total 19324
You can use the -d
option to show the number of subdirectories and the -s
option to show the size of each directory.
$ fcnt -s ./Pictures ./Music ./src/package
Path Files Dirs Size
./Pictures 7799 274 17.5G
./Music 3455 1196 21G
./src/package 8070 3120 4G
─────────────────────────────────
Total 19324 4590 42.6G
The -r
option can be used to filter files by regex and the -o
option sorts the results in descending order on the specified column.
# Count the number of ".py" files in each subdirectory of "src" and sort by files.
$ fcnt -r '\.py$' -o f src/*
Path Files
src/codebook/ 829
src/package/ 376
src/test/ 31
src/spiderman/ 7
src/Notes/ 0
─────────────────────
Total 1243
Dependencies
~3.5–5MB
~93K SLoC