我使用馬赫桌面呼應腳本的結果爲Desklet,所以它必須是這種格式:轉換AppleScript的一個行
回聲「告訴應用程序‘iTunes的’返回當前曲目的專輯」 | osascript
我有一個單行輸入數據,所以腳本需要是一個長字符串。 這可能是整個事情必須包含在一個單引號後面的回聲,如下所示:
echo'[entire script]'| osascript
如何將下面的AppleScript轉換爲一行?
set some_file to "Macintosh HD:Users:Zade:Library:Application Support:Notational Data:Words.txt" as alias
set the_text to read some_file as string
set the text item delimiters of AppleScript to ", "
set the_lines to (every text item of the_text)
return some item of the_lines
這裏是我嘗試:
echo 'set some_file to "Macintosh HD:Users:Zade:Library:Application Support:Notational Data:Words.txt" as alias -e set the_text to read some_file as string -e set the text item delimiters of AppleScript to ", " -e set the_lines to (every text item of the_text) -e return some item of the_lines' | osascript
而且它給出了這個錯誤:
107:112:語法錯誤: 「設置」 不能識別號後去。 (-2740)
不幸的是,我不知道從哪裏開始,特別是因爲它全部在一條線上。我認爲這對你們來說會很簡單。 – Zade 2012-01-11 20:38:48
@Zade你是對的,這很容易,但你只是把它變得比它需要的更復雜。查看我的編輯瞭解更多信息。 :) – fireshadow52 2012-01-12 00:59:07
@Zade我的意思是包含每個**個人**行,而不是整個事情。另外,哪個'set'做錯誤點?我沒有使用Mach Desktop,但根據我對使用'osascript'的瞭解,這些行由'-e'分隔,並且包含在單引號中。 – fireshadow52 2012-01-12 03:28:46