sizeable

Get the size of a folder by iterating through its subfiles and folders.


Keywords
folder, size
License
MIT
Install
npm install sizeable@0.1.4

Documentation

sizeable NPM Version

Get the size of a folder by iterating through its subfiles and folders

Installing

Local

npm i sizeable

Global

npm i -g sizeable

Usage

var sizeable = require('sizeable');

sizeable(myFolderPath, [options or ignore regex pattern], callback);

Example:

var sizeable = require('sizeable');
var folder = '/my/folder/path';

sizeable(folder, function callback(err, size, details) {
    if (err) {
        throw err;
    }

    console.log(size, 'bytes');
    console.log(sizeable.toKb(size), 'Kb');
    console.log(sizeable.toMb(size), 'Mb');
    console.log(sizeable.toGb(size), 'Gb');
    console.log(sizeable.toTb(size), 'Tb');

    console.log(sizeable.toFormat(size, 'b'), 'bytes');
    console.log(sizeable.toFormat(size, 'kb'), 'Kb'); // Valid format 'b', 'kb', 'mb', 'gb' and 'tb' (Ignore case)
});
var sizeable = require('sizeable');
var folder = '/my/folder/path';
var ignore = /node_modules/;

sizeable(folder, ignore, function callback(err, size, details) {
    if (err) {
        throw err;
    }

    sizeable.detailsSizeTo(details, 'mb', function(err, details) {
        if (err) {
            throw err;
        }
        console.log(JSON.stringify(details, null, 2));
    });
});
var sizeable = require('sizeable');
var folder = '/my/folder/path';
var ignore = /node_modules/;

sizeable(folder, ignore, function callback(err, size, details) {
    if (err) {
        throw err;
    }

    sizeable.detailsSizeTo(details, 'mb', function(err, details) {
        if (err) {
            throw err;
        }

        sizeable.sortDetailsBySize(details, function(err, details) {
            if (err) {
                throw err;
            }

            console.log(JSON.stringify(details, null, 2));
        });
    });
});

Options

ignore

Regular expresion for ignore folders or files

onlyFolders

Ignore all files

CLI tool

sizeable -f /my/folder/path -i "node_modules|.git"

# ~> 12.32 mb
sizeable -f /my/folder/path -i "node_modules|.git" -F gb

# ~> 0.12 gb

For show more information use -h

sizeable -h

License

MIT