Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: 10.4.3 update may break Automator workflows System 10.4
Tiger only hintIf you have Automator scripts that combine Finder actions with shell scripts, you may have some problems with 10.4.3. In particular, it appears that the 'Get Selected Finder Items' action has changed its behavior under 10.4.3, and not for the better. I've also come up with a bit of a kludge solution for the problem, but at least it works.

In a nutshell, the problem is that the path returned by Get Selected Finder Items isn't usable by the Run Shell Script action. So if you have a script that first gets the selected Finder items, and then tries to run a shell script on the selection, it will fail. I ran into this with my Autmator action for this hint, which worked fine in 10.4.2, but broke in 10.4.3. Read on to see what I've figured out thus far, along with my hacky solution.

To help debug the problem with my workflows, I inserted the View Results Automator action, to check on the returned values for various actions. When I used the 'Get Selected Finder Items' action for a chosen folder in the Finder, the View Results box looked like this:
{folder "TestBurn" of folder "Hints" of folder "personal"
 of disk "datastore" of application "Finder"}
This looked like an AppleScript path to me, not a shell-usable path. So I set out to try to find another way to send a selection to my Run Shell Script action. Instead of getting the selection, I switched to the Ask for Finder Items action, with the Type pop-up set to Folders, and the Allow Multiple Selection box checked. This presents a standard file selection dialog on the screen, from which you choose the itme(s) to be used. When I ran this one, the View Results box showed me this value:
{alias "datastore:personal:Hints:TestBurn:"}
This looked more like a shell path to me, so I then re-added my Run Shell Script action, and ... everything worked! Clearly, the path being returned by Get Selected Finder Items is not usable by the Run Shell Script action, but the Ask for Finder Items returns a workable path. Unfortunately, popping up a selection dialog box for every workflow isn't a very workable solution. So I went looking for a workaround, and surprising myself, managed to find one. It turns out that if you take an action, any action, on the Finder selection, then the path will be correct. What's the best action to add? One that doesn't do much of anything -- Label Finder Items, with the label set to None. So my final workflow now looks like this:

That's the 'make burnable' script I use, and it now once again works in 10.4.3. Unfortunately, the 'make unburnable' bug that I discussed in the above-linked hint still exists -- I can't unburn the folder once it's been switched. Ah well, maybe 10.4.4...
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[12,257 views]  

10.4: 10.4.3 update may break Automator workflows | 8 comments | Create New Account
Click here to return to the '10.4: 10.4.3 update may break Automator workflows' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: 10.4.3 update may break Automator workflows
Authored by: truhe on Nov 01, '05 08:36:43AM

At Automatorworld there's this action which might help: http://www.automatorworld.com/archives/get-unix-paths-of-files/



[ Reply to This | # ]
10.4: 10.4.3 update may break Automator workflows
Authored by: adrianm on Nov 01, '05 08:55:05AM

I don't have a Mac near me at the moment, but wouldn't it be better to have an apple script action that converts the finder item to a quoted posix path and then pass that on?

That would ensure that all paths would work, including ones with spaces, quotes, etc in them.

In fact, one should probably have done that in the first place.

Thinking further sideways, could the shell script action in your example be accomplished more easily with an applescript one?

I'm sure I'll realise why not when I get home :-)



[ Reply to This | # ]
10.4: 10.4.3 update may break Automator workflows
Authored by: adrianm on Nov 01, '05 12:37:57PM
Back on Mac (hurrah!)

I put this applescript action inbetween "Get Selected Finder Items" and your shell script action:


on run {input, parameters}
	set output to {}
	repeat with i in input
		set p to get POSIX path of (i as alias)
		set q to quoted form of p
		set end of output to (q as string)
	end repeat
	return output
end run
A bit verbose, but you get the idea.

[ Reply to This | # ]
10.4: 10.4.3 update may break Automator workflows
Authored by: robg on Nov 01, '05 02:18:47PM

I'm sure that works, but the bigger issue is why the handling of that Finder action changed from 10.4.2 to 10.4.3. All of the Finder actions that 'get' things should return the same style of string, but that's not currently happening.

I've been in touch with the Automator team, and they're looking into it; I'll post more later if I hear anything...

-rob.



[ Reply to This | # ]
My Workflows Seem to Be Fine
Authored by: nicksay on Nov 01, '05 07:30:59PM
I'd just like to report that I'm running 10.4.3 and my workflows seem to be fine.

In the above linked story, I posted one of the scripts to "toggle" burn folders.
What I did to create that workflow was:
1) Created a new workflow
2) Added a "Run Shell Script" action
3) Set "Shell:" to "/bin/bash"
4) Set "Pass input:" to "as arguments"
5) Pasted the following code in the text box:
for i in "$@"; do if [ -d "$i" ]; then
i="${i%/}"; f="${i##*/}"; p="${i%/*}"
[[ "$f" = "$p" ]] && p="."
[[ $f == *.fpbf ]] && n="${f%.fpbf}" || n="$f.fpbf"
mv -v "$i" "$p/$n"
fi; done
6) Saved as a Finder Plug-in

I was then able to select one or more items in the finder, right-/ctrl-click and choose my workflow, and any selected folders "toggled" from "normal" to "burn" and vice versa.

[ Reply to This | # ]
10.4: 10.4.3 update may break Automator workflows
Authored by: jacobolus on Nov 06, '05 11:42:28PM
The conversions between these types of inputs are really buggy in Automator. According to the documentation (maybe the developer documentation on making new actions, I don't remember), Automator is supposed to automatically convert applescript file references to POSIX paths for shell scripts, etc. It isn't happening now, and it's really annoying. Thanks for the tip about the labels though. I had been using an applescript like this:
on run {input, parameters}
	
	set myList to {}
	repeat with myItem in input
		set myItemPath to POSIX path of myItem as text
		set myList to myList & {myItemPath}
	end repeat
	
	return myList
end run
to do the conversions previously. It looks like this no longer works. I'll try the labels thing now.

[ Reply to This | # ]
10.4: 10.4.3 update may break Automator workflows
Authored by: windfate on Dec 01, '05 11:48:17AM

I was able to get POSIX paths working again under 10.4.3 by adding "as Unicode text" as below:

set itemPath to (quoted form of POSIX path of (a_file as Unicode text))



[ Reply to This | # ]
10.4: 10.4.3 update may break Automator workflows
Authored by: jacobolus on Nov 06, '05 11:52:16PM

I'd suggest using "filter finder items" with a filter that gets everything, like "name extension is not equal to 'automatorIsBuggyDamnit'", rather than the finder label action, which removes color labels on items that have them.



[ Reply to This | # ]