title: Applescript: Rename files in Finder by choosing from list
body: <p>I have so far working is showing the list of current files in a folder. I'd like to be able to choose one of those files from the list and rename it from a dialog but it doesn't seem to be working. Any ideas?</p>
  
  <pre><code>set scriptLocation to alias ((path to me as text) &amp; "Contents:Resources:")
  
  tell application "System Events"
      set filelist to name of every file in folder "Plugins" of scriptLocation whose name extension is "scpt"
  end tell
  repeat with aFile in filelist
      set contents of aFile to text 1 thru -6 of aFile
  end repeat
  
  set returnedInfo to (choose from list filelist OK button name "Rename" cancel button name "Back" with prompt "Choose a Script to rename" with title "Rename this File")
  
  set updatedInfo to the text returned of (display dialog "What would you like to rename " &amp; returnedInfo &amp; " to?" default answer returnedInfo buttons "Rename" default button 1)
  
  tell application "Finder"
      set the name of file ((path to me as text) &amp; "Contents:Resources:Plugins:" &amp; returnedInfo &amp; ".scpt") to updatedInfo &amp; ".scpt"
  end tell
  </code></pre>
  
  <p>Thank you so much for your help, working on a big project and this feature would be great if it worked..</p>