使用 AppleScript 更改当前工作目录 (cwd) 的最简单方法是什么。它相当于 OScd
或 Python 的os.chdir
. 如果一个不存在的目标目录会被即时创建(但这将是高度可选的),那就太好了。
问问题
3075 次
2 回答
1
If you are looking to use with an applications save dialog...
set filePath to "path/to/my/file"
tell application "System Events"
-- Once save dialog is open
keystroke "g" using {shift down, command down}
delay 1
set value of text field 1 of sheet 1 of sheet 1 of window 1 to filePath
end tell
于 2014-05-20T11:26:02.023 回答
1
你可能正在考虑做这样的事情:
tell application "Finder"
# ^^^ or whatever application you want to control up there
# to get to a file...
set filePath to POSIX file "/Users/username/Documents/new.mp3"
# to get to a folder...
set testFolder to POSIX path "/Users/username/test"
if (exists (folder testFolder)) then
say "folder exists"
else
make new folder at testFolder
endif
end tell
于 2014-05-20T05:53:09.140 回答