El comando curl en el comando do shell script está mal formado. La opción -o espera un nombre de archivo o un nombre de archivo de acceso completo y calificado no solo una ruta como lo que el < em> variable theFilePath contiene. Consulte la página de manual de curl , en un tipo de Terminal man curl y presione Intro y luego desplácese hacia abajo hasta -o, --output <file> donde dice: Write output to <file> instead of stdout.
Entonces, su comando do shell script debería verse así:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & "/" & theFile)
Si incluye el / (barra) al final del valor , usted configuró para la variable theFilePath , por ejemplo. set theFilePath to "/Volumes/home/Downloads/" puedes eliminar & "/" del comando do shell script , que luego se vería así:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & theFile)
Además, como ya ha configurado theFilePath , puede usarlo en su declaración tell application "Finder" , por ejemplo:
tell application "Finder" to open theFilePath as POSIX file
Si desea que el Finder active la apertura del archivo, y dependiendo de cómo configure theFilePath (con o sin / ), use uno de los siguientes métodos de manera adecuada:
tell application "Finder" to open (theFilePath & "/" & theFile) as POSIX file
tell application "Finder" to open (theFilePath & theFile) as POSIX file
El código de AppleScript que se muestra a continuación contiene ambas formas de la variable theFilePath y el comando do shell script junto con dos versiones de tell application "Finder" sentencia con un conjunto comentado con el líder -- (doble guión).
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