title: Applescript to add leading zeros to a filename, how?
body: <p>I need to rename files within subfolders so that the number prefix is three digits long.</p>
  
  <p>The name pattern is:
  1 Audio Track.aiff
  2 Audio Track.aiff
  etc...</p>
  
  <p>I have tried to figure out what to do but have so far only managed to get a solid headache.</p>
  
  <p>All help is appreciated.</p>
  
  <p>ps. I did find this subroutine but my scripting skills are sadly lacking to make good use of it.</p>
  
  <pre><code>on add_leading_zeros(this_number, max_leading_zeros)
   set the threshold_number to (10 ^ max_leading_zeros) as integer
   if this_number is less than the threshold_number then
   set the leading_zeros to ""
   set the digit_count to the length of ((this_number div 1) as string)
   set the character_count to (max_leading_zeros + 1) - digit_count
   repeat character_count times
   set the leading_zeros to (the leading_zeros &amp; "0") as string
   end repeat
   return (leading_zeros &amp; (this_number as text)) as string
   else
   return this_number as text
   end if
  end add_leading_zeros
  </code></pre>