1... 2... 3...
A (simple) directory and (plaintext) file counter, written in Python, for counting:
- Characters
- Words
- Lines
- Files
- Directories/folders
If the given path is a directory/folder, the all nested files and directories will also be included, until each possible edge (directory) has met an endpoint with no further directories within
For execution python>=3
needs to be installed, with the standard library, with the additional packages found in requirements.txt. These can be installed using pip
install
with the -r
flag - or simply by executing either:
./install.ps1
(Linux, macOS)
./install.sh
python counter.py "path/to/wherever" --flags --go --here
(Linux, macOS)
python3 counter.py "path/to/wherever" --flags --go --here
For the number of characters, tag a -c
flag, otherwise for a double-dash (literal) flag:
--char
--chars
--character
--characters
including special characters, for example "\n"
and "a"
are both 1 character
For the number of words, tag a -w
flag, otherwise for a double-dash (literal) flag:
--term
--terms
--word
--words
a word is either separated by spaces U+0020
or newline 0x000A
(escape sequence \n
)
For the number of lines, tag a -l
flag, otherwise for a double-dash (literal) flag:
--line
--lines
--newline
--newlines
a line is separated by a newline 0x000A
(escape sequence \n
), for unix-like systems (including modern Apple macOS) this works, and so too for Microsoft Windows - a newline of \r\n
For the number of files, tag a -f
flag, otherwise for a double-dash (literal) flag:
--doc
--docs
--document
--documents
--file
--files
determined by not os.path.isdir(some_path)
, effectively the same as os.path.isfile(some_path)
For the number of directories/folders, tag a -f
flag, otherwise for a double-dash (literal) flag:
--dir
--dirs
--directory
--directories
--folder
--folders
--album
--albums
determined by not os.path.isdir(some_path)
flags are commutative, the returned integer is the same (for the same path), no matter the order of flags. For example (the return of) -fd
is equal to -df
Following a single-dash -
, tag on single character flags, for example -fd
would return the sum of the number of files and directories/folders
For each literal flag wanted, tag on, a double-dash --
(prior), for example --files --folders
would return the sum of the number of files and directories/folders
refer above to flags, for valid literal flags (subject to extension with updates)