Reputation: 30985
While I was using Snow Leopard, I've used many times the following pattern when creating my Applescripts:
on run args
set filePath to POSIX file (item 1 of args) as alias
...
end run
After upgrading to Mountain Lion, the above script seems to produce a warning, though:
2012-08-10 15:12:12.305 osascript[54131:303]
CFURLGetFSRef was passed this URL which has no scheme
(the URL may not work with other CFURL routines): path/to/input/file.ext
Could anyone enlighten on the meaning of the error?
Upvotes: 3
Views: 1665
Reputation: 397
This should clarify the problem and solution. So first with the problem
TB1T-Bboot:$ cat tmp.applescript
tell application "Finder"
set MacOSpath to POSIX file "test-file" as alias
end tell
TB1T-Bboot:$ osascript tmp.applescript
2012-09-24 22:25:50.022 osascript[2564:707] CFURLGetFSRef was passed this URL which has no scheme (the URL may not work with other CFURL routines): test-file
alias TB1T-Bboot:Users:archive:test-file
TB1T-Bboot:$
Now without the problem:
TB1T-Bboot:$ cat tmp.applescript
tell application "Finder"
set MacOSpath to POSIX file "/Users/archive/test-file" as alias
end tell
TB1T-Bboot:$ osascript tmp.applescript
alias TB1T-Bboot:Users:archive:test-file
TB1T-Bboot:$
So it's complaining that the path is relative, not absolute. This warning doesn't come up in Lion.
Upvotes: 5
Reputation: 3638
A simple fix would be to prefix the path with file:///
. Mountain Lion expects URLs for everything, so a 'naked' path won't work.
For example, if you want /Users/RobertoAloi/file.txt you would pass in
file:///Users/RobertoAloi/file.txt`.
The details for CFURLGetFSRef can be found at https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html
Upvotes: 0