Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: Script / folder icon question

Would there be a script I can run in Apple Script Editor that changes several folder icons inside another folder all at once?

Posted on

Reply

Page content loaded

Jun 24, 2012 10:24 AM in response to JGcalifornia In response to JGcalifornia

I have a Cocoa-AppleScript application that changes icons - it can't be run from the AppleScript Editor, although the main script can be viewed and edited from there. The application doesn't go into folders, but multiple items can be selected or dropped onto the application (multiple items are set to the same icon). If this sounds like it will work, the application can be downloaded here, otherwise you will need to explain your workflow a bit better so that the application can be tweaked.

Jun 24, 2012 10:24 AM

Reply Helpful

Jun 26, 2012 4:51 PM in response to JGcalifornia In response to JGcalifornia

The easiest way to do this would be to create a Service Workflow using Automator, then you can select the desired items in a Finder window, and right-click to bring up a contextual menu where you can choose the service. Unfortunately, dealing with Automator is a bit of a pain sometimes, but Lion's Open Finder Items action (which doesn't want to cooperate with multiple items) can be worked around with an AppleScript action. I've tested the following workflow and it works for me (the Get Value of Variable action can be left out if you don't want the selected folders themselves to be changed). I've also updated my Set Icon application with dialogs that work better and included a progress indicator (for those 'tons of folders') - the application also uses a different bundle identifier, so you'll want to get the new version since that is what the Automator workflow looks for. The application can still be used on its own by double-clicking or dropping items on it (it won't decend into folders, though).


The workflow:

User uploaded file


The Script (paste into the Run AppleScript action):


propertybundleID : "com.Menace-Enterprises.Cocoa-AppleScript.Set-Icon"


onrun {input, parameters}



try-- use Spotlight to find the Set Icon application, wherever it may be

setappPathtofirstparagraphof (do shell script"mdfind " & quote & "kMDItemCFBundleIdentifier == " & quoted formofbundleID & quote)


onerrorerrmessnumbererrnum-- oops, not found

activateme-- bring dialog to front

display alert"Error " & errnummessage"Application 'Set Icon' was not found."

errornumber-128-- cancel


endtry



tellapplication"Finder"toopeninputusing (appPathasPOSIX file)


returninput

endrun

Jun 26, 2012 4:51 PM

Reply Helpful

Jun 27, 2012 9:23 AM in response to JGcalifornia In response to JGcalifornia

Well, they are all workflows, but you want to use the Service template - this will get added to the contextual menu. Also, the Open Finder Items action does work with multiple items in Snow Leopard, so you can also use that instead of the Run AppleScript action - just set it to open the items with the Set Icon application.

Jun 27, 2012 9:23 AM

Reply Helpful

Jun 27, 2012 9:45 AM in response to JGcalifornia In response to JGcalifornia

In Automator, the workflow is built by dragging an action from the library (on the left) into the document window (on the right). Depending on how the library is organized, the Get/Set Value of Variable actions will be under Utilities or Automator.


The Set Icon application is the application that does the actual setting of the icons, and can be downloaded using the links I posted earlier. The Automator service just gets the Finder selection via the contextual menu and passes the resulting list of folders to the application, so for the Open Finder Items action you will need to click on the popup and choose Other... to navigate to wherever you put the Set Icon application (the applescript tries to find the application by querying Spotlight).

Jun 27, 2012 9:45 AM

Reply Helpful

Jun 27, 2012 10:02 AM in response to JGcalifornia In response to JGcalifornia

The default script in the action is replaced by the new one, so make sure that the only thing in the Run AppleScript action window is the script I posted.


Edit: You may need to run the Set Icon application by itself so that the system sees it and it gets out of quarantine (just run it and cancel the dialog). As I mentioned, you can also use the Open Finder Items action instead of the script in Snow Leopard.

Jun 27, 2012 10:02 AM

Reply Helpful

Jun 27, 2012 10:23 AM in response to JGcalifornia In response to JGcalifornia

If wherever you unzipped/placed the Set Icon application is not indexed by Spotlight, it won't find it. At this point, you can just replace the Run AppleScript action with Open Finder Items, and manually navigate to wherever you put the Set Icon application.

Jun 27, 2012 10:23 AM

Reply Helpful

Jun 27, 2012 11:01 AM in response to JGcalifornia In response to JGcalifornia

If you are trying to run the workflow directly from Automator, it won't get any input, since that normally comes from the service runner (the items selected when choosing the service from the contextual menu). To test from inside Automator, you will need to (temporarily) add something like the Ask for Finder Items action to get something for the workflow to work with.


Also, your second Set Value of Variable action should be a Get Value of Variable action. The Get Folder Contents action doesn't return the original folder(s) that it gets the contents from, so to include the selected folders themselves, the original items are added back into the input.

Jun 27, 2012 11:01 AM

Reply Helpful
User profile for user: JGcalifornia

Question: Script / folder icon question