Skip to content

Show HN: Set OS X files and folders to self-destruct based on tag

scottmw.com
32 pointsturtleofdeath16 comments
On HN

Comments

If this was based on atime instead of mtime, and was coupled with Time Machine backups, it'd actually make an interesting form of Hierarchical Storage Management. Files would "expire" from your local disk, but still be restorable.

On a tangent, that's really what I (and I think most people) want from HSM—not "files canonically being on slow media but being cached on faster media", but rather "files canonically being on small/fast media, and then migrating to slower media when you stop caring about them, as if a garbage-collection pass had occurred, leaving your disk with more space." Basically, HSM should do automatically what people do manually when they e.g. burn files to optical disks to clear up space.

For easy-to-use OSX automation I'm a big fan of Hazel: http://www.noodlesoft.com/hazel.php

I bet you could set up something similar in it.

This is a pretty good idea. Add the ability to tag a file/files with TTL from the CLI as well.

Source code: https://github.com/tdlm/os-x-self-destruct

Add the ability to tag a file/files with TTL from the CLI as well.

You can use the OS's standard facilities to do what you want: see `xattr` and `mdfind`.[1] There's also `tag`[2]

  1 http://apple.stackexchange.com/questions/93979/are-the-osx-mavericks-tags-visible-from-the-command-line
  2 https://github.com/jdberry/tag

I'm using tag, too, but it's in C, so, I suggested xattr to the author. I submitted an issue already (first!): https://github.com/tdlm/os-x-self-destruct/issues/1

This is awesome. I've been waiting for Yosemite's JS Automation so I can do some similar things with my downloads (Moving into folders based on tags, etc.) so this is going to be fun to play around with.

It mentions it uses srm, is that any use with an SSD with wear levelling etc?

Probably not. Hopefully you're also using FileVault, though it doesn't totally alleviate recovery risks (from undelete scripts, etc)

Interesting idea, can anyone give me ideas for specific use cases in everyday use?

I use Hazel (mentioned by drhayes9 too) to monitor various folders and take action regularly. On the delete side, this includes:

* clearing out any items in Downloads > 1week * clearing out any items from my "Temp" folder > 1 day, unless they have an explicit "save" tag ("Temp" is my go-to alternative to the Desktop and is where I stash anything, well, temporary-ish) * automatically moving screenshots into my Temp folder (where they will soon be deleted)

An open-source, CLI-alternative is maid. It really allows me to scratch my programmer's itch.

https://github.com/benjaminoakes/maid

You know you can specify the folder screenshots are saved to by using:

    defaults write com.apple.screencapture location /Full/Path/To/Folder

Why not using /tmp?

1 Workflow: you can put the files anywhere this way, and still have them get deleted.

2 Time granularity (though you could, I suppose, set up subdirectories in /tmp/ with associated hourly/daily/weekly/monthly cronjobs)

Is there no at(1) on OSX?

Yes, you could queue an at job for every deletion. If you moved the file that approach would break. Also, you'd have to remove that at queue entry if you changed your mind.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.