
delay 0.5, with the value of the delay set appropriately.I am looking for a tool that will let me rename my photos upon impoting them from the camera/cardfile. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. Have a look at the try statement and error statement in the AppleScript Language Guide. The onus is upon the user to add any error handling as may be appropriate, needed or wanted.
A better finder rename will not quit code#
Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. If you'd like you be able to select folders in Finder and have the files within renamed, then create an Automator Service/Quick Action with the settings as shown in the image of the Automator Service/Quick Action below, adding a Run AppleScript action with the example AppleScript code.Įxample AppleScript code: on run Note: This Automator Folder Action is designed to receive a single folder at a time!ĭropping multiple folders will result in the all files having the name of the first folder dropped!įor multiple folders, see: Using an AppleScript script for the Folder ActionĪs an Automator Service/Quick Action for Finder If you need to act on files not having an extension, then the example AppleScript code will need to be modified to accommodate that condition.

The example AppleScript code, as coded, assumes files to be renamed have an extension. Set theseFiles to files of entire contents of thisItem Set folderName to name of thisItemsProperties If class of thisItemsProperties is folder then Set thisItemsProperties to properties of thisItem Using Script Editor, save the example AppleScript code to ~/Library/Scripts/Folder Action Scripts and use Folder Action Setup to assign it to the target folder.Įxample AppleScript code: on adding folder items to thisFolder after receiving theseNewItems One of its benefits is it can handle multiple folders being dropped at the same time into the target folder of the Folder Action. Here is another approach that uses an AppleScript script for the Folder Action. Using an AppleScript script for the Folder Action The image shown further below in this answer is of the actual working Automator Folder Action and why there is no Get Selected Finder Items action nor and green circle check marks, as it is run in the background when the Race Track 2019 folder is dropped into the DOIT folder.

There needs to be a logical break between this Set Value of Variable action and the ensuing Get Value of Variable action so as to then filter out the folder(s) as it's the files that will be renamed, not the folder(s). The first action, Set Value of Variable, is set to IncomingFolder and gets filtered in a Filter Finder Items action so as to get just the folder itself in order to use a Run Shell Script action to ascertain its name and assign it to the FolderName variable in the Set Value of Variable action.

In particular, the Options set on the Get Value of Variable action has Ignore this action's input checked.

In the Automator Folder Action image further below in this answer, pay attention to the Automator actions and their settings.
