Apple Script returns errors on path to folder.

Hi
I’m new to this, so the lingua is a bit strange to me.
But I’m trying to make an Apple Script work that exports videos from EyeTV to a folder using Elgato Turbo.264. The script declares some paths to where the script should place the new file:

[i]# all transcodes will be written to this path, then moved to the TARGET_PATH after export is complete

Note: This must be an absolute path. Do not begin this path with “~”.

property TEMP_PATH : “/usr/stigchristensen/Dokumenter/PlexTemp/”[/i]

But when I run the script I get an error message saying:

"System Events received an error: "Can’t get disk item “/usr/stigchristensen/Dokumenter/PlexTemp/”
(I have to say that my Apple Script runs in Danish language, so the actual returned error is my translation)

Why is this path wrong?

Try this, to verify if your path exists:

do shell script "open " & TARGET_PATH

/usr/ is a reserved location. You can’t do there as you like how on your desktop (path)

Just to show you how to open /usr/

tell application "System Events" to open alias "/usr/" 

Hi Joy

Thanks for your reply. Well it seems that whatever I do, the path to the folder isn’t going to work.
You know I’m new to this although I have done a bit of programming before.
It seems that your suggestion: do shell script "open " & TARGET_PATH require that the variable is defined right?
Well I tried to define it with property and moved the whole setup to another mac and here I wrote down the exact file path to a specific Dorico file:

“Macintosh SSD/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico”

I’m Danish and here we have some specialized letters!!

I took a picture so you can see that the path is right but I can’t find a way to upload it.

Hi. Welcome to MacScripter.

It’s difficult to know what to advise without seeing your script, but here are a few observations:

  1. As Joy says, /usr/ isn’t a location to which scripts should be writing. If “PlexTemp” is a folder in your Documents folder, the correct POSIX path to it is “/Users/stigchristensen/Dokumenter/PlexTemp/”.

  2. Two kinds of path may be used in AppleScript scripts: POSIX paths and HFS paths. POSIX paths have slashes for separators, as in “/Users/stigchristensen/Dokumenter/PlexTemp/”. They’re used in shell scripts and in AppleScriptObjC. HFS paths (the original Mac OS type) have colons, as in “Macintosh HD:Users:stigchristensen:Dokumenter:PlexTemp:” (if “Macintosh HD” is the name of your start-up volume). These are generally better where AppleScript itself or a scripted application has to access the files or folders. HFS paths should be used in conjunction with appropriate keywords to get explicit file or folder specifiers rather than just pieces of text. AppleScript has commands for converting POSIX paths to HFS and vice versa.

  3. A POSIX path always begins with a slash, which represents the current “mount point”. Unless it’s explicitly changed, this “mount point” is the volume from which the script’s run, so the name of the volume isn’t used in the path. But if the path refers to an item on another volume, it must begin with “/Volumes/” and the name of that volume:

If the script’s run from the volume “Macintosh SSD”: “/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico”
If it’s run from some other volume: “/Volumes/Macintosh SSD/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico”

HFS paths always begin with the name of the volume.

  1. The text parameter of do shell script is the source code of a script in its own right, so any strings within that script should be quoted to differentiate them from the commands in the text and from each other — especially if they contain spaces. AppleScript has a quoted form function which takes care of that:
set TARGET_PATH to "/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico" -- If running from Macintosh SSD.
-- Or:
set TARGET_PATH to "/Volumes/Macintosh SSD/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico" -- If running from another computer or volume.

do shell script ("open " & quoted form of TARGET_PATH)

Otherwise:

set TARGET_PATH to "Macintosh SSD:Brugere:Fælles:Dorico_Example_Projects:nr1.dorico"

tell application "System Events" to open alias TARGET_PATH
-- Or:
tell application "System Events" to open file TARGET_PATH
-- Or:
tell application "System Events" to open disk item TARGET_PATH

-- NB. In the context of System Events, 'alias' and 'file' are native System Events classes, not the AppleScript ones.

Or, converting a POSIX path to HFS (and thence to a System Events specifier):

set TARGET_PATH to "/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico" -- If running from Macintosh SSD.
-- Or:
set TARGET_PATH to "/Volumes/Macintosh SSD/Brugere/Fælles/Dorico_Example_Projects/nr1.dorico" -- If running from another computer or volume.

tell application "System Events" to open file (TARGET_PATH as POSIX file as text)

Or converting an HFS path to POSIX:

set TARGET_PATH to "Macintosh SSD:Brugere:Fælles:Dorico_Example_Projects:nr1.dorico"

do shell script ("open " & quoted form of POSIX path of TARGET_PATH)