How can I "touch" a file from the Mac UI?

6

3

I've encountered a situation where a Mac user needs to update the modified time of a file. If I was doing this, I'd just open up Terminal, cd to the file, and use the touch command. However, the person doing this is not me and I'd like to avoid making their lives more complicated with Linux commands. So, is there a simple way to touch a file from the OS X UI? This user will either be using Snow Leopard or Lion.

abeger

Posted 2012-05-24T17:04:32.963

Reputation: 725

3Opening the file, changing something, saving, undoing the change, and saving again isn't an option? – Daniel Beck – 2012-05-24T17:07:08.377

It's an audio file for one thing, which makes changing it a little dicier. That said, if I can provide them with a solution that doesn't involve opening another program, that'd be optimal. – abeger – 2012-05-24T17:10:22.377

Answers

9

Open Automator and create a new Application.

From the Library, add a Run Shell Script action that receives input as arguments.

Change the sample script from cat to touch and save, e.g. as Update Time anywhere on your system.

Zip the created application (File » Compress "Update Time" in Finder) and email the .zip file to your user with the instructions to:

  1. Save the attachment to the Downloads folder
  2. Double-click the saved file to extract the application
  3. Drag & drop the audio file onto the application (with the robot icon)

Daniel Beck

Posted 2012-05-24T17:04:32.963

Reputation: 98 421

If you want to use this yourself, an even easier method is to select 'service' instead of 'application'. Say that it accepts files/folders from finder as input. Then create the service the same way as Daniel Beck describes. Then save and call it 'Touch'. Then in finder you can just right click on a file and 'Touch' will appear in the menu. – Daniel Howard – 2016-05-31T11:19:57.067

This worked great for me. A note to anyone else following these instructions: Make sure you change the input type BEFORE you change the cat to touch. – abeger – 2012-05-25T19:36:13.887

0

If this is part of a recurring task then perhaps you could use this free touch tool:

http://www.macupdate.com/app/mac/32413/touch-files

Or, this AppleScript solution might work:

http://www.applefritter.com/node/13502

Jeremy

Posted 2012-05-24T17:04:32.963

Reputation: 616

2Your "AppleScript solution" is for Mac OS 9, obsolete for over a decade. The first link points to an Automator action, which requires understanding of Automator to use. Have you even looked at those before posting? – Daniel Beck – 2012-05-24T17:21:29.950

Yikes, sorry, I didn't notice it said OS 9 on the AppleScript solution (I found that right before I posted so I threw it in). As for the Automator solution, I just figured that if this was a recurring task it might be worth taking the time to setup for your user(s). However, based on what you're saying, a recurring solution isn't useful here. – Jeremy – 2012-05-24T17:48:32.907

It'd make sense for the case where you'd set it up for yourself, not like the user asked. I don't think there's a really immediate solution to do this on the GUI, unfortunately. The shell solution I describe would survive Automator action format changes, while being a bit more complicated to set up. – Daniel Beck – 2012-05-24T17:55:13.400