3 ms·
Is there a great advantage over standard shell commands, besides being in Ruby? For example, the following rule: rule 'Trash old temporary files' do dir(
by icebraining 14y ago
Is there a great advantage over standard shell commands, besides being in Ruby? For example, the following rule:
rule 'Trash old temporary files' do
dir('~/Outbox/*.tmp.*').each do |p|
trash(p) if 1.week.since?(modified_at(p))
end
end
can be replaced with:
#Trash old temporary files
find ~/Outbox/ -iname '*.tmp.*' -mtime +7 -exec mv {} ~/.Trash \;
The maid script may be more readable if you don't know 'find', but on the other hand, this has only one line.
- benjaminoakes 14y agoI used to use bash scripts and `find` for the purposes that you give. Maid came about when I was starting to add logging and a "dry run" option to those bash scripts. Ruby quickly became an attractive option then. But for many one-off tasks, I still find knowing how to use `bash`, `find`, etc effectively to be important. There are other benefits beyond logging and an easy to invoke "dry run" option. For example, many of the methods in the DSL give back arrays and strings, any of Ruby's many Enumerable methods are available to you. If you have any difficult-to-express logic, that can be quite handy. Also, not every OS keeps its trash at `~/.Trash`, but Maid will do the right thing on OS X or Linux. There are other reasons you might prefer Maid over shell scripts, but in general my hope is that Maid can provide a common framework for these types of scripts and also a community for people interested in automating tasks like this.