2010-12-20 26 views
1

Ich möchte einen neuen Ordnerbefehl in Apfelskript erstellenApplescript zum Erstellen neuer Ordner

Warum Dosent dieses Skript funktioniert?

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 

Antwort

22

Sie können es mehr direkt mit 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

Ich weiß nicht, ob bash läuft innerhalb Apple Befehle betrügt, aber Sie können auch tun:

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

Dies ist nützlich, wenn Sie Unterordner im laufenden Betrieb erstellen müssen, wenn sie noch nicht vorhanden sind:

do shell script "mkdir -p '~/Desktop/New Folder/Bleep/Bloop'" 
Verwandte Themen