fcnt

Crates.iofcnt
lib.rsfcnt
version0.2.8
sourcesrc
created_at2023-01-06 14:51:34.271426
updated_at2024-10-24 03:48:56.139005
descriptionfcnt is a cmd-line tool for counting the number of files in given directories.
homepagehttps://github.com/seamile/fcnt
repositoryhttps://github.com/seamile/fcnt
max_upload_size
id752333
size41,694
Seamile (seamile)

documentation

README

fcnt

Crates.io Crates.io

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
Commit count: 47

cargo fmt