curl Komut içinde do shell script komuta bozuk. Bu -o seçenek, yalnızca değişkenin içerdiği gibi bir yol değil, bir dosya adı veya tam nitelikli bir yol adı dosya adı bekler . Terminal türündeki man sayfasına bakın ve enter tuşuna basın ve ardından bulunduğu yere gidin: theFilePathcurlman curl-o, --output <file>Write output to <file> instead of stdout.
Yani do shell script komut gibi görünmelidir:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & "/" & theFile)
Eğer eklerseniz /sonunda (çizgi) değeri Eğer set için theFilePath değişken örneğin set theFilePath to "/Volumes/home/Downloads/"sen ortadan kaldırabilir & "/"gelen do shell script komutla sonra gibi görünecektir:
do shell script "curl " & quoted form of theFileURL & " -o " & quoted form of POSIX path of (theFilePath & theFile)
Ayrıca, belirlemiş beri theFilePathsize odasını kullanabilirler tell application "Finder" açıklamada , mesela:
tell application "Finder" to open theFilePath as POSIX file
Finder'ın dosyanın açılmasını tetiklemesini istiyorsanız ve nasıl ayarladığınıza bağlı olarak theFilePath(a ile veya a olmadan /) aşağıdakilerden birini uygun şekilde kullanın:
tell application "Finder" to open (theFilePath & "/" & theFile) as POSIX file
tell application "Finder" to open (theFilePath & theFile) as POSIX file
Aşağıda gösterilen AppleScript kodu theFilePath değişkenin hem formlarını hem de do shell script komutu , tell application "Finder" ifadenin iki sürümüyle birlikte satır başında --(çift çizgi) yorumlanmış bir setle birlikte içerir .
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 scriptkomutu , bu yüzden onları eklenditheFilePath & theFilevetheFilePath & "/" & theFileörneğin(theFilePath & theFile)ve(theFilePath & "/" & theFile)eğer öyleysetheFiledeğişken dosya adı boşluk vardır düzgün halledilir.