File path length checker
__ __ ___ __ __ /\ \__/\ \ /\_ \ /\ \__/\ \ _____ __ \ \ ,_\ \ \___\//\ \ __ ___ __\ \ ,_\ \ \___ /\ '__`\ /'__`\ \ \ \/\ \ _ `\\ \ \ /'__`\/' _ `\ /'_ `\ \ \/\ \ _ `\ \ \ \L\ \\ \L\.\_\ \ \_\ \ \ \ \\_\ \_/\ __//\ \/\ \/\ \L\ \ \ \_\ \ \ \ \ \ \ ,__/ \__/.\_\\ \__\\ \_\ \_\\____\ \____\ \_\ \_\ \____ \ \__\\ \_\ \_\ \ \ \/ \/__/\/_/ \/__/ \/_/\/_//____/\/____/\/_/\/_/\/___L\ \/__/ \/_/\/_/ \ \_\ /\____/ \/_/ \_/__/
Install from npm:
$ npm install pathlength
Usage: pathlength [options] [target] Options: -h, --help output usage information -V, --version output the version number -d, --debug output debug messages -f, --filter [expression] filter expression to use -n, --no-headers don't output headers for certain formats -o, --output [format] format for output -p, --progressive output matches as they are found -r, --recursive check directories recursively -s, --stop don't search unfiltered directories
Recursively check for all files within a
Temp directory with a path longer
than 255 characters:
$ pathlength -rf ">255" ~/Temp
Check for paths length longer than that of the target file/directory:
$ pathlength -rf ">@" ~/Temp
Format the result output as a padded table with headers:
$ pathlength -ro table -f ">@" ~/Temp
Path Length Type /Users/neocotic/Temp/bar.txt 28 File /Users/neocotic/Temp/foo.txt 28 File /Users/neocotic/Temp/sub 24 Directory /Users/neocotic/Temp/sub/baz.txt 32 File /Users/neocotic/Temp/sub/fu.txt 31 File
Output the results of the search as they are found:
$ pathlength -rpf ">@" ~/Temp
$ pathlength -o $FORMAT ~/Temp
"path": "/Users/neocotic/Temp""length": 20"type": "Directory"
-n|--no-headersoption is used
Path Length Type /Users/neocotic/Temp 20 Directory
find([options][, callback]) is used primarily:
var pathlength = require'pathlength'pathlengthfindfilter: 'lte' '255'recursive: truetarget: '~/Temp'if err throw err// Process data set...
The following options are recognised by this method (all of which are optional);
|context||Context in which to call the callback function|
|filter||Filter expression used to check files/directories|
|recursive||Check directories recursively|
|stop||Don't check children of unfiltered directories|
|target||Target file/directory to check|
Get notified whenever a matching file/directory has been found:
var pathlength = require'pathlength'pathlengthon'data'// Process data...pathlengthfindfilter: 'gt @'recursive: truetarget: '~/Temp'
The following events can be triggered by this method;
|start||...after handling all arguments|
|afterStart||...before the first beforeData event|
|betweenData||...before all other beforeData events|
|beforeData||...before all data events (
|data||...when the result has been stored in the data set (
|afterData||...after all data events (
|beforeEnd||...after the last afterData event (
|end||...in parallel with the callback function (
pathlengthon'end'dataSetforEachconsole.logdatapath // e.g. /Users/neocotic/Tempconsole.logdatalength // e.g. 20console.logdatadirectory // e.g. true
Filters simply consist of a comparison operator followed by an operand.
A wildcard (
*) character replaces any invalid filter component(s), which will
result in all files and directories being included in the results.
||Not equal to|
||Greater than or equal to|
||Less than or equal to|
Operands can consist of numeric characters or one of the following special characters, which are replaced with their corresponding value:
||Length of the target file/directory|
If you have any problems with this library or would like to see the changes currently in development you can do so here;
Take a look at
docs/pathlength.html to get a better understanding of what the code is doing.
If that doesn't help, feel free to follow me on Twitter, @neocotic.
However, if you want more information or examples of using this library please visit the project's homepage;