GithubHelp home page GithubHelp logo

ivansowerby / counter Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7 KB

Plaintext character/word/line counter for specified files and/or folders

License: MIT License

Python 93.10% PowerShell 3.50% Shell 3.40%

counter's Introduction

Counter

1... 2... 3...

Brief Introductions

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

Installation


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:

Powershell

./install.ps1

Bourne shell

(Linux, macOS)

./install.sh

Execution


Windows

python counter.py "path/to/wherever" --flags --go --here

Unix-like

(Linux, macOS)

python3 counter.py "path/to/wherever" --flags --go --here

Flags


Characters

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

Words

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)

Lines

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

Files

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)

Directories/folders

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)

Combinations


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

Single-dash

Following a single-dash -, tag on single character flags, for example -fd would return the sum of the number of files and directories/folders

Double-dash

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.