당신의 가장 큰 문제는 당신이 (콜론) 맥 스타일의 경로를 사용해야하는 경우 (슬래시 사용) POSIX 스타일 경로를 사용하고 있습니다. AppleScript는 콜론으로 구분 된 경로를 사용합니다. t 사이에 "posix path"를 사용하여 콜론에서 슬래시로 이동하고 "posix file"을 사용하여 슬래시에서 콜론으로 이동합니다.
그리고 경로를 문자열로 전달할 수 없습니다. applescript에서 우리는 파일 지정자 (file specifiers)를 사용합니다 ... 그래서 나는 파일을 문자열 경로 앞에 놓습니다. 우리가 수정하면 이렇게 작동합니다.
set posixPath to "/Users/abc/Downloads/02331_veiledinclouds_2560x1600.jpg"
set macPath to (POSIX file posixPath) as text
tell application "URL Access Scripting"
download "http://interfacelift.com/wallpaper_beta/grab/02331_veiledinclouds_2560x1600.jpg" to file macPath
end tell
그러나 다운로드 한 파일의 파일 이름을 31 문자로 줄이기 때문에 파일 이름 길이 문제가 발생합니다.
편집 : 필요한 경우 파일을 잘라내어 다운로드하고 이름을 바꾸는 스크립트입니다.
set posixPath to "/Users/abc/Downloads/02331_veiledinclouds_2560x1600.jpg"
set baseName to do shell script "/usr/bin/basename " & quoted form of posixPath
set needsRenaming to false
if (count of baseName) is greater than 31 then
set downloadName to text -31 thru -1 of baseName
set basePath to do shell script "/usr/bin/dirname " & quoted form of posixPath
set posixPath to basePath & "/" & downloadName
set needsRenaming to true
end if
set macPath to (POSIX file posixPath) as text
tell application "URL Access Scripting"
download "http://interfacelift.com/wallpaper_beta/grab/02331_veiledinclouds_2560x1600.jpg" to file macPath
end tell
if needsRenaming then
tell application "Finder"
set name of file macPath to baseName
end tell
end if
잘 연주했습니다. 나는 그렇게 생각조차하지 않았다. –