2014-05-20 3 views
1

AppleScript를 사용하여 현재 작업 디렉토리 (cwd)를 변경하는 가장 간단한 방법은 무엇입니까? OS의 cd 또는 파이썬의 os.chdir과 동일합니다. 대상 디렉토리가 존재하지 않는다면 즉시 작성 될 수 있지만 (매우 선택적 일 수 있음) 훌륭합니다.AppleScript를 사용하여 현재 작업 디렉토리를 변경하는 방법

+0

[** 쉘 명령으로 AppleScript로 스크립트를 실행 **] (https://developer.apple.com/library/mac /documentation/applescript/conceptual/applescriptx/concepts/work_with_as.html#//apple_ref/doc/uid/TP40001568-1148121) –

답변

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 
1

이 같은 일을 생각 될 수 있습니다 내가 답변 on this pagethis related question (또는 this one) 떨어져 내 대답을 내놓고있어

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 

. 당신이 응용 프로그램과 함께 사용하고자하는 경우

+0

제안에 감사드립니다! AppleScript를 사용하여 타사 응용 프로그램 (예 : Chrome 또는 Firefox)을 시작 (시작/실행)하고 있습니다. AppleScript를 사용해야하는 이유가 있습니다. 응용 프로그램이 시작되면'홈 디렉토리 '를'/ Applications/Firefox.app/Contents'와 같은 기본 응용 프로그램 폴더로 설정합니다. 따라서 모든 파일 열기, 파일 저장이 기본 응용 프로그램 폴더에서 열립니다. 응용 프로그램을 시작하기 전에 현재 작업 디렉토리를 선택한 디렉토리로 변경하여이 내용을 무시하고 싶습니다. 필자는'tell application "Finder"를 이런 상황에서 사용할 수 없다는 것을 두려워합니다. 다른 제안? – alphanumeric

관련 문제