If you are like me you find yourself at the command line to do things you learned 30+ years ago. Or maybe you do things at the command line you learned last year! Yesterday?
Well, if you’re lazy like me you’ve come to the right place to learn how to do this.
I use “touch” all the time to bring the file date/time up to “now”. This will sort my files to what I’m working on right now when I look at them in Finder.
Like so many other hours in a day I finally came to the realization that I could code this with automator very simply and easily. It turns out I was right.
The idea is to use automator to run a BASH script to do this for you. Here is that process.
- Open up Automator.app located in your Applications folder.
- Choose ”Service” in the dialog sheet when creating a new document.
- In the Services receives selected: menu at the top of the ”Canvas” on the right, change to ”Files & Folders”.
- In the sidebar to the left, search for Get Selected Finder Items
- Drag this Action to the ”canvas” on the right side.
- Again, go to the sidebar at the left and this time search for Run Shell Script
- Drag the Run Shell Script action to the ”canvas” on the right side.
- At the right in the Run Shell Script action, change the Pass input from to stdin to as arguments
You are going to install this script code:
for f in "$@" do touch "$f" done
The code is simple. It just says “take this list” and “touch” each one of them.
Here is what it’ll look like in automator:
Since this is something I’ll use every day I figured I would publish it. No rocket science here but very helpful repetitive task perfect for a computer to do every day for you.