Il comando curl nel comando do shell script non è corretto. L'opzione -o si aspetta un nomefile o un nome di percorso completo nomefile non solo un percorso come quello < em> variabile theFilePath contiene. Vedi la pagina man per curl , in un tipo Terminale man curl e premi invio e scorri verso il basso fino a -o, --output <file> dove afferma: Write output to <file> instead of stdout.
Quindi il tuo do shell script comando dovrebbe essere simile a:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & "/" & theFile)
Se includi il / (barra) alla fine del valore tu set per la theFilePath variabile ad es. set theFilePath to "/Volumes/home/Downloads/" puoi eliminare & "/" dal do shell script comando , che sarebbe quindi simile a:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & theFile)
Inoltre, poiché hai già impostato theFilePath , puoi utilizzarlo nella tua tell application "Finder" istruzione , ad es.
tell application "Finder" to open theFilePath as POSIX file
Se vuoi che Finder attivi l'apertura del file e, a seconda di come imposti theFilePath (con o senza / ), utilizza uno dei seguenti appropriatamente:
tell application "Finder" to open (theFilePath & "/" & theFile) as POSIX file
tell application "Finder" to open (theFilePath & theFile) as POSIX file
Il codice di AppleScript mostrato sotto contiene entrambe le forme della variabile theFilePath e il comando do shell script insieme a due versioni del tell application "Finder" istruzione con un set commentato con il principale -- (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 " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & "/" & theFile)
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & 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:" & return & theFile & return & return & 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 & "/" & theFile) as POSIX file
-- tell application "Finder" to open (theFilePath & theFile) as POSIX file