A simple tool to organize your directories based on predicates.
The configuration for dirclean uses ini files.
Sections denote a directory, and within that patterns, actions, and watching behaviours tell dirclean how to function with that directory.
For instance:
[~/Downloads] # Section denotes this acts on all files in directory ~/Downloads
pattern = `*\.zip` # only select files matching pattern, see selectors supported
move_to = "zip" # Move to new folder, see actions supported
watch = true # watch files in directory (via inotify).
[~/Downloads] # Can have the same directory multiple times
pattern = >2d
delete = true
watch = false
poll = 60m # scan directory hourly
Action | Description |
---|---|
move_to | Move files to directory (create if needed), with pattern matching support |
delete | Delete files |
exec | Run command with file passed as argument |
Pattern matching allows the use of regex to intelligently rename files. It utilizes regex capture groups to achieve this.
For instance you could use (.+)\.zip
, which would capture the filename of only
zip files. You could then use the move_to
action to move this file to another
folder of the same filename like zip/{}/
. So for instance hello.zip
would be placed at zip/hello/hello.zip
.
# Example of pattern matching
[~/Downloads]
# Match mp3 files that follow the regex "{artist} - {title}.mp3"
pattern = `(.+) - (.+)\.mp3$`
move_to = "~/Music/{}/{}/"
watch = true
Selector | Description |
---|---|
pattern | Match files based on regex |
age | Match files based on age |
Simply run dirclean
to start the daemon, it’ll silently work in the background
to clean the directories as specified by your configuration.