Publishers of technology books, eBooks, and videos for creative people

Home > Blogs > Mac Productivity: Quick Scripts and Workflows - Add Date to Files and Folders

Mac Productivity: Quick Scripts and Workflows - Add Date to Files and Folders

By  Apr 2, 2012

Topics: Apple, Operating Systems, Productivity

Keeping files and folders organized on my Mac is essential to my productivity.  Folder structures and naming conventions are a big help, but I also need to ways to quickly locate meeting or phone call notes from last Tuesday, or the samples a client sent me for review last October.  One method I use is to add date prefixes to certain file and folder names.  This provides visual clues when I’m browsing for something, and also allows me to sort more easily.  While the methodology works, I don’t like having to keep typing the date over and over again.  Although it only takes a few seconds, it’s repetitive, and sometimes I enter a typo.  Since my time is extremely limited, those few seconds are also valuable to me.  To make life easier, I’ve created an Automator Service that appends a date prefix to files and folders in the Finder.  Here’s how you can do the same...

1. Launch Automator (in /Applications)

2. When prompted to choose a type of workflow, select Service and click Choose

Creating an Automator Service workflow

3. Set the popup menus at the top of the workflow area to receive files or folders in the Finder

Setting the Service to process files or folders in the Finder

4. Search for the Rename Finder Items action, and drag it to the workflow area.  When you do this, Automator displays an alert, indicating that the action will change the names of your files, and that this renaming cannot be undone.  Automator suggests inserting a Copy Finder Items action first, to back up your files, and gives you the option to automatically insert it into the workflow.

Automator suggests working with copies of files and folders prior to performing undoable actions

Since the workflow will append the current date to existing file or folder names, backing up the files first is probably an unnecessary step.  So, click Don’t Add to instruct Automator not to add the additional Copy Finder Items action to the workflow.

5. The Rename Finder Items action appears in the workflow area, and it "links up" with the header.  This tells you that the action receives input.  When the workflow runs, any selected files or folders in the Finder are automatically passed to this action for processing.  Configure the Rename Finder Items action to add the current date/time before the file name, with a space as the first separator, a dash as the second separator, a format of Year Month Day, and leading zeros.  The example text at the bottom of the action should show YYYY-MM-DD Item

The completed workflow, which adds the date to file or folder names

6. Save the workflow, and name it Files & Folders • Add Date to Selected Items

Saving the Automator workflow as a Service

Automator puts the workflow where it needs to go (into the ~/Library/Services folder), and enables it.  Anytime you want to add the date to a file or folder, select one or more files or folders in the Finder.  Then, choose Finder > Services > Files & Folders • Add Date to Selected Items from the menu bar.

Running the workflow from the menu bar

Or, Control+Click on the selected items, and choose Services > Files & Folders • Add Date to Selected Items from the contextual menu.

Running the workflow from the Finder’s contextual menu

If everything goes according to plan, then the current date, in the format YYYY-MM-DD, is added as a prefix to the names of the selected items.

A file, whose name includes a date prefix

For more on Automator, check out my book  Automator for Mac OS X: Visual QuickStart Guide, as well as my video podcast series Mac Automation Made Simple.