我正在編寫一個蘋果腳本,最終將爲來自EyeTV的所有iTunes導出標記商業廣告。但是我遇到了AppleScript路徑的一個簡單問題,即EyeTV應用程序返回的記錄位置。這裏的背景:從AppleScript路徑中提取文件擴展名
set recordingID to 370404006
set myid to recordingID as integer
tell application "EyeTV"
set eyetvr_file to get the location of recording id myid as alias
end tell
return eyetvr_file
別名 「蘋果HD2:文件:EyeTV的存檔:南Park.eyetv:000000001613eaa6.eyetvr」
現在我需要提取包含路徑和文件前綴000000001613eaa6(使用this question),所以我可以在文件000000001613eaa6.edl中查找相應的商業標記。這裏的打嗝:
tell application "Finder"
set eyetv_path to container of eyetvr_file
set root_name to name of eyetvr_file
set fext to name extension of eyetvr_file
end tell
的結果是,
eyetv_path:文檔文件 「南Park.eyetv」 文件夾中的 「EyeTV的歸檔」 文件夾盤的 「文檔」 中的 「Macintosh HD2」 應用「發現者」
ROOT_NAME: 「000000001613eaa6.eyetvr」
FEXT: 「」
fext應該是「.eyetvr」,而不是空字符串。如何從eyetvr_file或root_name中正確提取「.eyetvr」?我已經嘗試了一堆黑客像
set fext to name extension of (eyetvr_file as document)
但是這給喜歡錯誤,
錯誤「無法使別名\」蘋果HD2:文件:EyeTV的存檔:南Park.eyetv: 「000000001613eaa6.eyetvr \」轉換成文檔類型。「編號-1700從別名「Macintosh HD2:Documents:EyeTV Archive:South Park.eyetv:000000001613eaa6.eyetvr」到文檔
謝謝!這適用於下面的編輯,並提供了一個更好的解決方案,我鏈接到一個。除非我指定「AppleScript的文本項目分隔符」,否則此代碼給了我一個錯誤,並且我還保存了以前的設置以用於較大的代碼塊中:「set delims to AppleScript's text item delims
set AppleScript's text item delimiters to」。「
…設置AppleScript的文本項目分隔符以定界「 – stvs