My Favorite Automation Hack
It’s the simple things in life that are most extraordinary.
— Paulo Coelho
I am in the habit of adding a date prefix to many of the files I name. For example, if I have a file named New Microsoft Word Document.docx
, I tend to rename it 2020-12-22--New Microsoft Word Document.docx
.
As far as the date in the filename is concerned, I pick a date that is most meaningful to me. Most of the time that means creation date, but sometimes I’ll pick a different date, if it makes more sense, depending on the content of the file.
You may wonder…what is the point of doing this? Doesn’t the file system already capture timestamps like this for you?
And the answer is, yes, of course, it almost certainly does. However — what happens when you move a file from one filesystem to another (i.e. ext4
to FAT32
or NTFS
to ISO 9660
). Are you sure that you will retain the timestamp that matters to you?
This technique for naming files ultimately lends itself towards building collections of files that can tell a very simple story, with a crude timeline, simply by issuing an ls
command in Linux or a dir
command in cmd.exe
on Windows. The same is true if you sort the list of files by name in a graphical user interface like Windows Explorer.
The thing is, typing out YYYY-MM-DD
gets to be pretty tedious after a while. So I developed keyboard shortcuts for myself on both Windows and Linux (XFCE) so that when I press CTRL+SHIFT+1
, I get today’s date.
With that new shortcut, I only have to type the same three keys every time, where everyone else needs to type ten keys that change every day. That may not seem like a big deal, but if you do this a lot, the savings of time and effort really begin to add up over the years!
Here’s how I create those shortcuts.
Today’s Date Hotkey for Windows
On Windows, I use the incredibly handy AutoHotkey.
Although the official AutoHotkey installer requires admin credentials, AutoHotkey does not need them to run.
If you don’t have admin credentials, the folks behind AutoHotkey offer a zipped version of AutoHotkey here: https://www.autohotkey.com/download/
Download the zip version and unzip to a location that works for you, like %USERPROFILE%
.
To get your copy of AutoHotkeys to run reliably, when you log in, simply create a shortcut to your choice to AutoHotkeyU32.exe
or AutoHotkeyU64.exe
in your Startup folder.
In Windows 10, the Startup folder is more obscure than it used to be. To get to your Startup folder in Windows 10: WIN+R
, shell:startup
. (Can’t get to the Run
dialogue with WIN+R
? You can just type shell:startup
into Window Explorer’s location bar, hit enter, and get the same result.)
This AutoHotkey script does what I want:
According to AutoHotkey’s documentation:
So to keep things simple, it’s best to save that script to a file named %USERPROFILE%\My Documents\AutoHotkey.ahk
or to %USERPROFILE%\Documents\AutoHotkey.ahk
, depending on your version of Windows.
Today’s Date Hotkey for Linux (XFCE)
Over on Linux, I tend to use XFCE as my window manager. To achieve the same effect that I have with AutoHotkey on Microsoft Windows, I turn to xdotool.
This almost does what I want:
The last part to making this work is actually mapping that logic to a hotkey. Here’s how I do it in XFCE.
About the Quote at the Beginning of the Post
I’m wasn’t familiar with Paulo Coelho until I started researching quotes about simplicity for this post. The quote appears to come from his novel The Alchemist. I have not read Coelho’s The Alchemist, but the quote has such a ring of truth to it, I had to borrow it from him.