2

AppleScript を使用して現在の作業ディレクトリ (cwd) を変更する最も簡単な方法は何でしょうか。OScdや Python のos.chdir. 宛先ディレクトリが存在しない場合は、オンザフライで作成されると便利です (ただし、これは非常にオプションです)。

4

2 に答える 2

1

アプリケーションの保存ダイアログで使用する場合...

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 に答える