#cleanup #resources #cli #hard-disk

bin+lib neaten

An application to cleanup resources from hard drive

19 releases

Uses new Rust 2024

new 0.1.20 Mar 29, 2025
0.1.19 Mar 20, 2025

#304 in Command line utilities

Download history 93/week @ 2025-03-12 1411/week @ 2025-03-19

1,504 downloads per month

MIT license

38KB
778 lines

Introduction

An application to cleanup resources from hard drive.

COMMAND

neaten - Command to cleanup resources from hard drive

SYNOPSIS

neaten  -c, --config        <config_file>
        -d, --destination   <destination_folder>
        -k, --kind          <folder/file>
        -p, --patterns      <comma_sep_string>
        -e, --exclude       <comma_sep_string>
            --dryrun        <bool>
        -h, --help

DESCRIPTION

Command to cleanup resources from hard drive. command will remove all files or folders mentioned in patterns from destionation & it's sub directories.

You can remove files/folders for a specific destination directory or from multiple destination directories.

If you want to remove files/folder from a specific directory, then pass destination, kind & patterns as argument.

neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target,dist"

or

neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target" --patterns "dist"

For multiple destination directories pass config argument with config file path which configured with multiple destination directories.

 neaten --config "/usr/sample/config.json"

Config file must be a json file. There is no specific name for config file, you can choose any name.

Root object of the config file must be an array. Here is the format of each config option:


{
    "destination": "<destination_path>",
    "kind": "folder/file",
    "patterns": ["pattern1", "pattern2"],
    "exclude": ["exclude1", "exclude2", "exclude3"]
}

exclude is an optional field.

Refer Config file Sample section for more about config file.

If you provide both config & destination, kind, patterns combo, command will continue with config argument.

You can dry-run to check which files or folders will be removed if execute the command. You can dry-run with optional argument dryrun.

Refer EXAMPLES section for more examples of how to use the command.

OPTIONS

-c, --config <path>_
 Config file with path(absolute or relative path). Config file must be in json format.

-d, --destination <path>
 destination directory path(absolute or relative path).

-k, --kind <enum>
 what kind of item wants to remove. It's an enum type with value: folder or file.

-p, --patterns <string>
 List of patterns to remove(comma separated value). Pass a comma(,) separated string or call multiple time.

-e, --exclude <string>
 List of items to be excluded from remove(comma separated value). Pass a comma(,) separated string or call multiple time.

--dryrun <enum>
 dry-run mode to check list of item to be removed.

-h, --help
 Display help for the command.

EXAMPLES

  • Remove using config file.
$ neaten --config "/usr/sample/config.json"
$ neaten -c "/usr/sample/config.json"
  • Remove folders by passing destionation, kind & patterns arguments.
$ neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target"
$ neaten -d "/usr/sample/rust" -k "folder" -p "target"

$ neaten --destination "/usr/sample/node" --kind "folder" --patterns "dist,node_modules"
$ neaten -d "/usr/sample/node" -k "folder" -p "dist,node_modules"

$ neaten --destination "/usr/sample/node" --kind "folder" --patterns dist --patterns node_modules
$ neaten -d "/usr/sample/node" -k "folder" -p dist -p node_modules
  • Remove files by passing destionation, kind & patterns arguments.
$ neaten --destination "/usr/sample/rust" --kind "file" --patterns "exe"
$ neaten -d "/usr/sample/rust" -k "file" -p "exe"

$ neaten --destination "/usr/sample/node" --kind "file" --patterns "txt,log"
$ neaten -d "/usr/sample/node" -k "file" -p "txt,log"

$ neaten --destination "/usr/sample/node" --kind "file" --patterns txt --patterns "log"
$ neaten -d "/usr/sample/node" -k "file" -p txt -p "log"
  • Remove items but exclude some items.
$ neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target" --exclude "obj"
$ neaten -d "/usr/sample/rust" -k "folder" -p "target" -e "obj"

$ neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target" --exclude "obj,dist"
$ neaten -d "/usr/sample/rust" -k "folder" -p "target" -e "obj,dist"

$ neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target" --exclude "obj" --exclude "dist"
$ neaten -d "/usr/sample/rust" -k "folder" -p "target" -e "obj" -e "dist"
  • Dry-run with destionation, kind & patterns arguments.
$ neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target" --exclude "obj" --dryrun
$ neaten -d "/usr/sample/rust" -k "folder" -p "target" -e "obj" --dryrun

$ neaten --destination "/usr/sample/rust" --kind "folder" --patterns "target" --dryrun
$ neaten -d "/usr/sample/rust" -k "folder" -p "target" --dryrun
  • Dry-run with config arguments.
$ neaten --config "/usr/sample/config.json" --dryrun
$ neaten -c "/usr/sample/config.json" --dryrun

Config file Sample

Remove folder with or without exclude optional field

Currently removing of folder support full folder name, no regular expression support is there. You must provide full folder name in fields like: patterns, exclude.

[
  {
    "destination": "/usr/sample/rust",
    "kind": "folder",
    "patterns": ["target"],
    "exclude": ["special_sub_folder", "another_folder"]
  },
  {
    "destination": "/usr/sample/node",
    "kind": "folder",
    "patterns": ["dist", "node_modules"]
  },
  {
    "destination": "/usr/sample/C++",
    "kind": "folder",
    "patterns": ["build", "Debug", "Release"]
  }
]

Remove file with or without exclude optional field

Currently removing of files support full extension name, no regular expression support is there. You must provide full extension name in the fieldpatterns. For optional field exclude you need to provide full file name.

[
  {
    "destination": "/usr/sample/rust",
    "kind": "file",
    "patterns": ["toml"],
    "exclude": ["cargo.toml"]
  },
  {
    "destination": "/usr/sample/node",
    "kind": "file",
    "patterns": ["txt", "log"]
  },
  {
    "destination": "/usr/sample/C++",
    "kind": "file",
    "patterns": ["exe", "obj", "log"]
  }
]

Remove folder and file with or without exclude optional field

[
  {
    "destination": "/usr/sample/rust",
    "kind": "folder",
    "patterns": ["target"],
    "exclude": ["special_sub_folder", "another_folder"]
  },
  {
    "destination": "/usr/sample/rust",
    "kind": "file",
    "patterns": ["toml"],
    "exclude": ["cargo.toml"]
  },
  {
    "destination": "/usr/sample/node",
    "kind": "folder",
    "patterns": ["dist", "node_modules"]
  },
  {
    "destination": "/usr/sample/node",
    "kind": "file",
    "patterns": ["txt", "log"]
  },
  {
    "destination": "/usr/sample/C++",
    "kind": "folder",
    "patterns": ["build", "Debug", "Release"]
  },
  {
    "destination": "/usr/sample/C++",
    "kind": "file",
    "patterns": ["exe", "obj", "log"]
  }
]

Dependencies

~1.6–2.6MB
~50K SLoC