2010-12-20 23 views
1

私はリンゴスクリプトで新しいFolderコマンドを作成したい新しいフォルダを作成するAppleScript

なぜこのスクリプトは使えますか?

tell application "Finder" 
activate 
end tell 
tell application "System Events" 
tell process "Finder" 
    tell menu bar 1 
     tell menu bar item "File" 
      tell menu "File" 
       click menu item "New folder" 
      end tell 
     end tell 
    end tell 
end tell 
end tell 

答えて

22

あなたはAppleScriptのとよ​​り直接的にそれを行うことができます。

tell application "Finder" 
    set p to path to desktop -- Or whatever path you want 
    make new folder at p with properties {name:"New Folder"} 
end tell 
1
tell application "Finder" 
activate 
end tell 
tell application "System Events" 
tell process "Finder" 
    tell menu bar 1 
     tell menu bar item "File" 
      tell menu "File" 
       click menu item "new folder" 
      end tell 
     end tell 
    end tell 
end tell 
end tell 

--you capitalize the N in new folder the new folder button is not capped. 
0

のAppleScript内のbashコマンドを実行すると浮気されていますが、も行うことができる場合、私は知らない。

do shell script "mkdir '~/Desktop/New Folder'" 

サブフォルダがまだ存在しないときにオンザフライでサブフォルダを作成する必要がある場合に便利です。

do shell script "mkdir -p '~/Desktop/New Folder/Bleep/Bloop'" 
関連する問題