Organize One-Off Task Files with Dated Work Directories

Say you’re about to begin a task that will involve working with some files. Perhaps you’re creating a diagram or encoding some GIFs. Where do you put the files?

It’s tempting to use the desktop, but that quickly becomes unsustainable.

For a decade or so, I’ve placed artifacts like this in dated directories like ~/datedwork/2018.06.23-grep-production-logs. This works well for a few reasons:

  • I don’t have to think about it.
  • It lets me work from a clean slate.
  • It’s easy to find later (on the rare occasion that I need it).
  • It stays out of my way.
  • The date prefix prevents name collisions and helps me quickly find that thing I did last summer.

If you don’t already have a system that works well for you, I recommend trying this method. I also recommend automating it.

Make the Easy Easier

I’m a little embarrassed to admit that I’ve only automated this recently. Here’s the handy fish shell function I use:


function workdir -d "Create and switch to a dated work dir"
  set dir ~/datedwork/(date "+%Y.%m.%d")"-$argv[1]"
  mkdir -p $dir
  cd $dir
end

And, for everyone else, here’s a Bash version you can drop in ~/.bashrc:


workdir() {
    dir="$HOME/datedwork/"`date "+%Y.%m.%d"`"-$1"
    mkdir -p $dir
    cd $dir
}

With the shell function in place, a clean slate is one quick workdir do-the-thing command away. Compared to glancing at the date and typing a longer mkdir command, this slight reduction in effort seems trivial, but it has made a noticable difference in my workflow.

Before automating, I’d often subconsciously avoid the ceremony of creating a special directory, choosing to clutter up some more-accessible folder instead. Making this task as easy as possible makes me more likely to reach for the better solution.

Conclusion

The nested sort directories on my desktop prove that I’m not a perfectly organized computer user, but this technique helps a lot. It’s also fun to look back at a chronlogical journal of the random tasks I’ve worked on over the years.
How do you organize files like this?