AppleScript : Download to a AFP drive I try to download files to a AFP drive but always have "Warning: Failed to create the file /Volumes/home/Downloads: Is a directory
"

But the last command work fine 
    tell application "Finder" to open ("/Volumes/home/Downloads" as POSIX file) 

set theFileURL to the clipboard
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set theFile to text item -1 of theFileURL
set AppleScript's text item delimiters to TID

set theFilePath to "/Volumes/home/Downloads"
try
    do shell script "curl " &amp; quoted form of theFileURL &amp; " -o " &amp; quoted form of POSIX path of theFilePath
    display dialog "The download is finished!" buttons {"OK"} default button 1 with icon note giving up after 5
on error theError
    display dialog "Error downloading the file:" &amp; return &amp; theFile &amp; return &amp; return &amp; theError buttons {"OK"} default button 1 with icon 0 giving up after 5
end try


tell application "Finder" to open ("/Volumes/home/Downloads" as POSIX file)


in the same kind of script, I'm also to download torrent to my Synology Download Station if anyone have a clue.
The curl command in the do shell script command is malformed.  The -o option expects a filename or a fully qualified pathname filename not just a path like what the variable theFilePath contains.  See the man page for curl, in a Terminal type man curl and press enter and then scroll down to -o, --output &lt;file&gt; where it states: Write output to &lt;file&gt; instead of stdout.

So your do shell script command should look like:

do shell script "curl " &amp; quoted form of theFileURL &amp; " -o " &amp; quoted form of POSIX path of (theFilePath &amp; "/" &amp; theFile)


If you include the / (slash) at the end of the value you set for the theFilePath variable e.g. set theFilePath to "/Volumes/home/Downloads/" you can eliminate &amp; "/" from the do shell script command, which would then look like:

do shell script "curl " &amp; quoted form of theFileURL &amp; " -o " &amp; quoted form of POSIX path of (theFilePath &amp; theFile)


Additionally, since you have already set theFilePath you can use that in your tell application "Finder" statement, e.g:

tell application "Finder" to open theFilePath as POSIX file


If you want Finder to trigger the opening of the file, and depending on how you set theFilePath (with or without a /) use one of the following appropriately:

tell application "Finder" to open (theFilePath &amp; "/" &amp; theFile) as POSIX file
tell application "Finder" to open (theFilePath &amp; theFile) as POSIX file


The AppleScript code shown below contains both forms of the theFilePath variable and the do shell script command along with two version of the tell application "Finder" statement with one set commented out with the leading -- (double-dash).

set theFileURL to the clipboard
set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set theFile to text item -1 of theFileURL
set AppleScript's text item delimiters to TID

-- set theFilePath to "/Volumes/home/Downloads"
set theFilePath to "/Volumes/home/Downloads/"

try
    -- do shell script "curl " &amp; quoted form of theFileURL &amp; " -o " &amp; quoted form of POSIX path of (theFilePath &amp; "/" &amp; theFile)

    do shell script "curl " &amp; quoted form of theFileURL &amp; " -o " &amp; quoted form of POSIX path of (theFilePath &amp; theFile)

    display dialog "The download is finished!" buttons {"OK"} default button 1 with icon note giving up after 5
on error theError
    display dialog "Error downloading the file:" &amp; return &amp; theFile &amp; return &amp; return &amp; theError buttons {"OK"} default button 1 with icon 0 giving up after 5
end try

tell application "Finder" to open theFilePath as POSIX file
-- tell application "Finder" to open (theFilePath &amp; "/" &amp; theFile) as POSIX file
-- tell application "Finder" to open (theFilePath &amp; theFile) as POSIX file