2012-08-04 4 views
0

일부 파일을 드롭 박스에 백업하는 데 applescript를 사용하려고합니다. 내 질문은 내 스크립트에서 여러 개의 IF statmens 결합 할 수있는 경우 및 Macintosh HD : 사용자 : svkrzn : Dropbox to ~ : Dropbox 같은 SET 이름 TO 경로를 줄이는 것이 가능한 경우.애플 스크립트 - 여러 IF 구문과 홈 폴더의 약어를 결합합니다.

여기 내 스크립트입니다

set destination to "Macintosh HD:Users:svkrzn:Dropbox:Backup" 
set safari to "Macintosh HD:Users:svkrzn:Library:Safari:Bookmarks.plist" 
set safariplist to "Macintosh HD:Users:svkrzn:Dropbox:Backup:Safari_Bookmarks.plist" 
set things to "Macintosh HD:Users:svkrzn:Library:Application Support:Cultured Code:Things:Database.xml" 
set thingsxml to "Macintosh HD:Users:svkrzn:Dropbox:Backup:THINGS_Database.xml" 

tell application "Finder" 
    try 
    set S1 to duplicate file safari to folder destination with replacing 
    set T1 to duplicate file things to folder destination with replacing 
    if exists file safariplist then 
     display dialog "It exists." 
     delete file safariplist 
    end if 
    if exists file thingsxml then 
     display dialog "It exists." 
     delete file thingsxml 
    end if 
    set name of S1 to "Safari_Bookmarks.plist" 
    set name of T1 to "THINGS_Database.xml" 
on error 
    display dialog "Oops, a problem occurred duplicating the file." 
end try 
end tell 

답변

0

문 AppleScript로에서

if something then 
    -- do something 
else if somethingElse then 
    -- do something else 
else if anotherThing then 
    -- do the other thing 
else 
    -- if none of the others are true then do this 
end if 

우리가 명령을 표준 폴더로 얻을 수있는 "경로"를 사용 ...이처럼 할 수 있습니다. Applescript는 많은 표준 폴더를 알고 있습니다. AppleScript 편집기를 열고 "창"메뉴에서 "라이브러리"를 선택하십시오. "Standard Additions"애플리케이션을 찾아 더블 클릭하여 Applescript의 Standard Additions 사전을 엽니 다. "path to"를 검색하고 Applescript가 알고있는 모든 표준 폴더를보십시오.

당신이 할 수있는 예를 들어

...

set destination to (path to home folder as text) & "Dropbox:Backup" 
관련 문제