title: Applescript for changing filenames
body: <p>I would like to change thousand of filenames with an applescript.</p>
  
  <p>The filenames are all made in this way:</p>
  
  <p>firstPart - secondPart XX.xxx</p>
  
  <p>with the XX a certain number and the .xxx either a jpg or a png extension.</p>
  
  <p>I would like to simply change the parts around so that it would become:</p>
  
  <p>secondPart - firstPart XX.xxx</p>
  
  <p>I have come up with this but my codings skills fail me.</p>
  
  <pre><code>tell application "Finder" to set aList to every file in folder "ImageRename"
  set text item delimiters to {" - ", "."}
  repeat with i from 1 to number of items in aList
      set aFile to (item i of aList)
      try
          set fileName to name of aFile
          set firstPart to text item 1 of fileName
          set secondPart to text item 2 of fileName
          set thirdPart to text item 3 of fileName
          set newName to secondPart &amp; " - " &amp; firstPart &amp; "." &amp; thirdPart
          set name of aFile to newName
      end try
  end repeat
  </code></pre>
  
  <p>This works only the number sticks to the second part.
  So it becomes:</p>
  
  <p>SecondPart XX - firstPart.xxx</p>
  
  <p>How can I make two integers as a text item delimiter?</p>
  
  <p>Please help me out and teach me along the way :-)</p>