title: Shell script to rename files
body: <p>I wrote a small shell script based on an example I found here: <a href="https://bbs.archlinux.org/viewtopic.php?id=36305" rel="nofollow noreferrer">https://bbs.archlinux.org/viewtopic.php?id=36305</a></p>
  
  <p>it takes this:</p>
  
  <pre><code>bash-3.2$ ls
  test 001  test 002  test 003  test 004
  </code></pre>
  
  <p>and turns it into:</p>
  
  <pre><code>bash-3.2$ ls
  001  002  003  004  rename.sh
  </code></pre>
  
  <p>However it gives me this error (even though it works):</p>
  
  <pre><code>bash-3.2$ ./rename.sh
  mv: missing destination file operand after `rename.sh'
  Try `mv --help' for more information.
  `test 001' -&gt; `001'
  `test 002' -&gt; `002'
  `test 003' -&gt; `003'
  `test 004' -&gt; `004'
  </code></pre>
  
  <p>Though it works correctly, it would be nice to see where I messed up, I assumed by default it would put the files in the same directory (this is the desired output).</p>
  
  <pre><code>#!/bin/bash
  ls | while read -r FILE
  do
          mv -v "$FILE" `echo $FILE | awk -F ' ' '{print $2}'`
  done
  </code></pre>
  
  <p>Thanks in advance for helping me correct my incorrect code.</p>