title: How to assign results from printf statement to a variable (for leading zeroes)?
body: <p>I'm writing a shell script (Bash on Mac OS X) to rename a bunch of image files. I want the results to be:</p>
  
  <pre><code>frame_001
  frame_002
  frame_003
  </code></pre>
  
  <p>etc.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>let framenr=$[1 + (y * cols * resolutions) + (x * resolutions) + res]
  echo $framenr:
  let framename=$(printf 'frame_%03d' $framenr)
  echo $framename
  </code></pre>
  
  <p><code>$framenr</code> looks correct, but <code>$framename</code> always becomes <code>0</code>. Why?</p>