title: Listing all the files in a folder using JavaScript for Automation on Yosemite
body: <p>I'm trying to port some old Applescript over to the new JavaScript syntax.</p>
  
  <p>Somethings seem to be pretty straight forward so :</p>
  
  <pre><code>tell application "System Events" to keystroke "t" using command down
  </code></pre>
  
  <p>becomes :</p>
  
  <pre><code>System = Application('System Events');
  System.keystroke("t", {using: "command down"})
  </code></pre>
  
  <p>However I can't for the life of me work out how to list files at a specific location. In AppleScript, to return me a list of the files in the <code>/usr</code> directory, you would do :</p>
  
  <pre><code>tell application "System Events" to set fileList to name of items in folder "/usr"
  -- &gt; {"bin", "include", "lib", "libexec", "local", "sbin", "share", "standalone", "X11"}
  </code></pre>
  
  <p>However I can't for the life of me work out how to do it in Javascript. </p>
  
  <pre><code>System = Application('System Events')
  myPath = Path("/usr")
  
  fileList = System.items(myPath) 
  -- &gt; message not understood
  
  fileList = System.folder(myPath)
  -- &gt; message not understood
  
  fileList = System.diskItems(myPath)
  -- &gt; []
  
  fileList = System.diskItems({at:myPath)
  -- &gt; []
  </code></pre>
  
  <p>I've tried a whole lot of other combinations too, but no luck. Any ideas?</p>