Skip to main content

A super customizable file cleaner/organizer/automator

Project description

nought Share the word!

nought is a super customizable file cleaner/organizer/automator that can help keep you organized. It lets you have complete control over all of it's options (there are many)

Installation

Note: Please ensure that you have Python 3.6+ and pip installed on your computer before completing the following steps:

THIS TOOL HAS NOT BEEN TESTED FOR WINDOWS. USE AT YOUR OWN RISK FOR WINDOWS...

User only install: sudo pip3 install nought --user System wide install: sudo pip3 install nought

Usage

usage: nought [options] [identifiers ...]
    Runs `nought`, the super customizable file cleaner/organizer/automator

    Options:
			-c [location], --config [location]  	specify configuration file. Default: "./nought.toml" (see -d and "Environment Variables")
			-b [location], --backup [location]		backup files to specified location. Default: false
			-d, --default		set the config file as default
			-a, --about			display version and exit
			-h, --help			display this help message
			-t, --test			test configuration without actually doing anything (enables verbose mode)

    Arguments:
			IDENTIFIERS:		a repeatable identifier for which groups to run

    Environment Variables:
			NOUGHT_CONFIG:  the path to the default configuration file

For example, to run the r1 routine in config file /etc/nought/conf.toml after backing up all directories you would run: nought -bc /etc/nought/conf.toml r1 The default config file location is stored in the NOUGHT_CONFIG environment variable.

Configuration

The configuration file is a toml file where you set routines and rules. Here is an example one with comments:

[general]
base_dir = "~/" # (optional, default="./") The starting directory 

[[group]] # This entire section can be repeatable
path = "~/Desktop" # A string OR list of the location(s) the group applies to. (required)
id = "test" # (optional, default="./") A string OR list of identifiers (used in command line). If none is supplied, it is applied for all ids. If it is "default", then it is applied when no id is specified in command. 
recursive = true # (optional, default="./") Whether or not edit files recursively.
include_dirs = true # (optional, default="./") Whether to treat directories as files. WARNING: DIRECTORIES INCLUDE ALL FILES IN THEM!

	[[group.rule]] # Repeatable per group, matches file

	# Below are all the conditions that can be used to match files. ALL conditions must be met to perform action:
	# All values in underscore curly braces (_{code here}) are evaluated as python expressions, like this: "./home/${2*90}/test.txt" turns to "./home/180/test.txt"
	includes = [".jpg",".png"] # A list of non regex strings to search for IN FILENAME
	regex = '[Ss]creenshot(.*?)' # A regex string to match filename against. Capturing groups can be reused later. Use single quotes.
	size_less_than = 12 # Number of bytes (use less than 0 for empty files)
	size_more_than = 2 # Number of bytes
	content_includes = "text" # A non regex string to search for in file CONTENT
	custom = "len(open('$name').read().split()) > 2" # A python expression that returns True or False. `$name` is substituted with filename.
	modified_before = 8736423423 # A Unix timestamp in seconds. Negative values are subtracted from current time.
	modified_after = -1978263 # A Unix timestamp in seconds. Negative values are subtracted from current time.
	user = "root" # Matches Unix user name
	group = "www-data" # Matches Unix group name

	# `action` can be one of the following:
	action = "move" # Moves or renames file
	action = "delete" # Deletes file
	action = "script" # Runs a script

	move_to = "folder" # moves into folder
	move_to = "screenshots/$1/$name" # moves using regex backreferences and `$name` replacement.

	script = "nano $name" # $name is replaced with file

	[group.other] # this matches all files that haven't been matched (single brackets)
	action = "move"
	move_to = "other"

All values in underscore curly braces (_{code here}) are evaluated as python expressions, like this: ./home/_{2*90}/test.txt turns to ./home/180/test.txt $bp is replaced with the starting path or the rule. $bd is replaced with the base dir of the entire config file.

Upcoming

I will be adding NOT conditions soon.

Contribution

Please submit a PR if you want to help! It would be especially helpful if someone tests for windows.

Contact

If you need any help with anything, even how to write your config file, contact: cole@colewilson.xyz

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nought-1.0.8.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

nought-1.0.8-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file nought-1.0.8.tar.gz.

File metadata

  • Download URL: nought-1.0.8.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for nought-1.0.8.tar.gz
Algorithm Hash digest
SHA256 8536389a9ae8670ece4a97281cb1573692a6e1042fe4cbf71d3840fbea2cd907
MD5 645e65204e6985d86ee056bbb3ac41b7
BLAKE2b-256 c9cb8ffac86b58e1e1362f41e600f6b4ef15c9a751ddc4fee2ba5906de809a5e

See more details on using hashes here.

File details

Details for the file nought-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: nought-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for nought-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 6f632364b2c0293e0b5ca2c3e9b2dfc0a449f84acbb78507c4fbee9d9288b206
MD5 6669312ea6ea5f64ef9e43c2b712736f
BLAKE2b-256 378f01be915cb50915349f9df375955abbd9ad7f51c147a24f4c733fa5ad7b0c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page