First AppleScript Effort – Automatic Folder Action

June 26th, 2010  Posted at   Uncategorized
arrow   |   1 Commentarrow

As mentioned on my previous post, I began an effort to write some AppleScript to help me with some auto file naming on scanning I was doing. The general method I decided to employ was to build a Folder Action that would watch for new files to be added to the Desktop, and then if a file matching a certain obscure name existed, rename it automatically.

So I would make Image Capture write its output to a file called “scan_to_auto_rename.pdf” in the Desktop folder. The new folder action would see this file appear, then rename it to something like this: scan_yyyymmdd_hhmmss.pdf. In human that’s “scan_” plus the year, month, day, hours, minutes, and seconds.

To accomplish this, I had to write an AppleScript, drop it into /Library/Scripts/Folder Action Scripts/, then add the Folder Action via the UI. To add the action (assuming the script is written (correctly :) and located in the right place), go into Finder and right click the folder to which you want to add the action.

So I went to my home directory, right clicked on the Desktop folder, and selected “Folder Actions Setup…”. That popped up a dialog with a list of available scripts I could add. I scrolled down and found mine, aptly named “rename_scan_file.scpt”, selected it, and clicked Attach. That applied my script to the folder, and assuming my script was written correctly it would do something useful based on events taking place within/on that folder.

See next post for a look at the script itself.

One Response to “First AppleScript Effort – Automatic Folder Action”

  1. Michael Says says:

    [...] About « First AppleScript Effort – Automatic Folder Action [...]

Leave a Reply

You must be logged in to post a comment.