這似乎是這樣一個容易的事情做,我很驚訝的解決方案仍然躲過我。AppleScript選擇文件對話框存儲在文本文件中打開的最後一個文件夾。
我試圖存儲由「選擇文件」對話框打開的最後一個文件夾。我想將該文件夾的位置存儲在文本文件中。
我想讓我的「選擇文件」對話框總是打開到最後使用的文件夾。
我有很多的腳本工作,但有一個奇怪的事情,不斷逃避我。
看我的劇本......
set Shows to paragraphs of (read POSIX file "/Users/lowken/Documents/config.txt")
set strPathFromConfig to item 1 of Shows as string
set strPathFromConfig to ((characters 3 thru -1 of strPathFromConfig) as string)
display dialog strPathFromConfig
set strPath to (path to home folder as text) & strPathFromConfig
display dialog strPath
choose file with prompt "Please choose a file:" of type {"XLSX", "APPL"} default location alias strPath
的腳本讀取其中包含一條線,只有一個的「文檔」字符串我的配置文本文件。
我修剪了一些前導垃圾字符,並顯示一個對話框,其結果爲「Documents」。
然後我使用配置文件中的值設置strPath。
我顯示新值,它是我的系統上的有效位置。
接下來,我嘗試了對話,我得到的「文件別名的Macintosh HD的錯誤信息:用戶:lowken:中未找到文件
讓改變腳本,這樣,而不是使用值從文件的config.txt提取,我只是在我的腳本中設置一個字符串變量。
set Shows to paragraphs of (read POSIX file "/Users/lowken/Documents/config.txt")
set strPathFromConfig to item 1 of Shows as string
set strPathFromConfig to ((characters 3 thru -1 of strPathFromConfig) as string)
display dialog strPathFromConfig
set strTemp to "Documents"
set strPath to (path to home folder as text) & strTemp
display dialog strPath
choose file with prompt "Please choose a file:" of type {"XLSX", "APPL"} default location alias strPath
現在,它的工作原理。AppleScript的似乎不希望使用從config.txt的文件擡頭的價值。
我做錯了什麼?我試着鑄造到別名我在我的系統上嘗試了不同的位置。
在我看來,從文本文件查找的值不是字符串數據類型。
任何想法?
P.S.
我在2012年年中的MacBook Pro上運行OS X Yosemite 10.10.4。
我認爲可能就是這樣。至少它對我有意義。 – codingguy3000
這樣做。如何在世界上所有的好名字中輸入«&»符號?我能夠複製和粘貼它來運行,但我很想知道如何鍵入這些符號。 – codingguy3000
這取決於鍵盤。在** U.S。**鍵盤上: 按** Shift + \鍵**鍵入左側雙角括號。 按** Option + Shift + \ keys **鍵入右側雙角括號。 – jackjr300