3
1
I am writing some AppleScript in an Automator workflow, and I need to get the parent folder of a file (or folder) object. I have searched all over for this, and gotten the same answers, which are to use the "container", "parent", or "folder" properties. However, none of these work for me, whether or not they are wrapped in a 'tell "Finder"' block.
Thus, if I try something like:
set a to POSIX file "/usr/local"
tell application "Finder"
set b to container of a
end tell
display alert a
I get the error message 'Can’t get container of file "Macintosh HD:usr:local".' The same thing happens with parent and folder.
Furthermore, if I do "display alert class of a", I get "furl". This is in AppleScript Editor. On the other hand, an Automator workflow with a Run Applescript module with the text
on run {input, parameters}
repeat with i from 1 to length of input
set the_file to item i of input
display alert class of the_file
end repeat
return input
end run
displays "1634494835" in an alert box. But if I use "return class of the_file" instead, and use the View Results module, it shows the result as {alias}. Despite these strange class designations, I can use regular alias and file properties such as "POSIX path", with the file object.
Does anybody have any clue what's going on here? Is my AppleScript library broken or something?
What exactly is the problem with the second part of your question? It seems to behave as intended...? – Daniel Beck – 2012-01-08T22:33:18.737
1The number 1634494835 is the integer representation of the
'alis'
OSType
, which is what theOSType
of the AppleScriptalias
class is. – NSGod – 2012-01-10T04:55:47.270