Open nikolay opened 10 years ago
Do you mean tagging with a general self-destruct tag and then reading in the TTL as another tag?
This is what I meant:
./self-destruct.sh ~/Pr0n/*.mpg --after 1d
Thanks. I like it and am working on that in a branch.
@tdlm Can you push anything semi-working on that branch? I'd like to help. Also it would be great if you could do --after 10m
or --after 3d
.
@mauvm I haven't had a chance to work on this in a few days. I actually got stuck on a way to parse the time without resorting to dependencies. I too would like this sort of format!
The path I was going down was just porting that input into the 'date' command like so:
$ date && date -v +10M
Tue Oct 7 19:03:24 PDT 2014
Tue Oct 7 19:13:24 PDT 2014
Using date -v +10M or date -v +${SOME_VAR} it seems would work when altered to just output seconds:
$ date -r 0 -v +10M +"%s"
600
$ date -r 0 -v +1d +"%s"
86400
$ date -r 0 -v +3d +"%s"
259200
This is fine and dandy. The only real trouble there would be security on the command input for date and making sure people know the difference between '10M' and '10m' because it's a big one. I almost think you would want a confirmation unless you specified --force|-f.
Any input here is appreciated.
@tdlm Running date -r 0 -v +10M
gives me date: invalid option -- 'v'
. So I'm not sure what's the difference here. Are you on OS X 10.9.5 too?
What works for me is date -d "+3 Minutes"
. This also eliminates your problem. Because you can simply substitute the modifier with the tag name: date -d "+$TAG_NAME"
.
I was thinking more along the lines of also allowing tags like "3 Days". After a quick Google search I found that you can get all tags by running:
mdfind -0 "(kMDItemUserTags == '*')" | xargs -0 mdls -name kMDItemUserTags | grep '^ ' | cut -c5- | cut -d , -f 1 | sort -u
Which results in something like:
3 Days
1 Day
Green
This enables us to make the run
command dynamic by reading all tags (with regexes for example) and translating them to the required timestamp. This eventually replaces all the hardcoded delete commands, like secure_delete_files_for_tag_after_seconds "1 Minute" 60
.
Finally we can add a command that adds the desired tag:
self-destruct ~/Pr0n/*.mpg --after="3 Days"
Let me know what you think.
@nikolay I found a really simple solution:
brew install tag
tag --add "1 Day" ~/Pr0n/*.mpg
This would be nice as it could be used from other scripts.