El curl comando en el do shell script comando está mal formado. La -o opción espera un nombre de archivo o un nombre de archivo de ruta completo, no solo una ruta como la que theFilePath contiene la variable . Vea la página de manual para curl, en un tipo de Terminal, man curlpresione enter y luego desplácese hacia abajo hasta -o, --output <file>donde dice:Write output to <file> instead of stdout.
Entonces su do shell script comando debería verse así:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & "/" & theFile)
Si incluye la /(barra) al final del valor que estableció para la theFilePath variable, por ejemplo set theFilePath to "/Volumes/home/Downloads/", puede eliminar & "/"del do shell script comando , 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 lo ha configurado theFilePath, puede usarlo en su tell application "Finder" declaración , por ejemplo:
tell application "Finder" to open theFilePath as POSIX file
Si desea que Finder active la apertura del archivo y, según cómo lo configure theFilePath(con o sin a /), use uno de los siguientes de manera apropiada:
tell application "Finder" to open (theFilePath & "/" & theFile) as POSIX file
tell application "Finder" to open (theFilePath & theFile) as POSIX file
El código AppleScript que se muestra a continuación contiene ambas formas de la theFilePath variable y el do shell script comando junto con dos versiones de la tell application "Finder" declaración con un conjunto comentado con el inicio --(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
do shell scriptcomando , por lo que los agregó atheFilePath & theFile, ytheFilePath & "/" & theFilepor ejemplo,(theFilePath & theFile)y(theFilePath & "/" & theFile)por lo que si latheFilevariable de nombre de archivo tiene espacios se maneja adecuadamente.