title: Rename files to hash and extension
body: <p>The question was answered <a href="https://stackoverflow.com/questions/8201729/rename-files-to-md5-sum-extension-bash">here</a> to the OP's liking, but I couldn't make it work 100% for me. What I want to do is take files in <code>/home/hermit/Documents/Pictures</code> and hash it before putting the new files in <code>/home/hermit/Documents/HashPictures</code>, while keeping the file in <code>/home/hermit/Documents/</code>. Unfortunately, the solution <strong>doesn't</strong> seem to work for GIFs and JPGs.</p>
  
  <blockquote>
    <p>Or GNU sed can do it even shorter:</p>
    
    <p><code># md5sum * | sed -e 's/\([^ ]*\) \(.*\(\..*\)\)$/mv -v \2 \1\3/e'</code></p>
  </blockquote>
  
  <p>Another thing that would be nice is if I could have a script that is easily read or an explanation to go along with the script.</p>
  
  <p>EDIT: These are the remaining files (in <code>/home/hermit/Documents/Pictures</code> and terminal output. Remaining files: <a href="https://i.stack.imgur.com/Z4NAZ.png" rel="nofollow noreferrer">File names inside</a></p>
  
  <pre class="lang-none prettyprint-override"><code>hermit@hermit:~/Documents/PicturesHashed$ ./hash.sh
  mv: target '9c48b6846aa3211ba867d9775aa9a730.jpg' is not a directory
  mv: target '6cef7445eb7382aa719e364dc2d0126c.jpg' is not a directory
  mv: target 'b3624eae0010f7d042af838859d5ea0e.png' is not a directory
  mv: target '12f8f700cc73abe05da61103184f2ed0.jpg' is not a directory
  mv: target '340e018ba57016f469a1039fb19c2619.jpg' is not a directory
  mv: target '89da545ea3084500cd86a6265676173c.jpg' is not a directory
  mv: target '7ff0671fc0447ca009d216670a0e2ac9.gif' is not a directory
  mv: target '300d7e1e9807701f1a5043de85992484.jpg' is not a directory
  mv: target 'c340521eec897957c0a7d6f415232ae4.png' is not a directory
  mv: target '263ef6fd0b8623227a705bbcecb61755.gif' is not a directory
  mv: target '2f4e522461ff467d5b4a09b7d33c2114.jpg' is not a directory
  mv: target '2372edeb385381540d2230266ad5a4d2.png' is not a directory
  mv: target 'bf5fc13be51d281347e0b00694c7689b.jpg' is not a directory
  mv: target '3ab04030a8d06ff5aa5dca406c3927b0.jpg' is not a directory
  mv: target '84d61abe2ff50e81d96e9b5ca916048e.jpg' is not a directory
  mv: target 'c1c74496d880e4a20403c65e583dff54.jpg' is not a directory
  mv: target '99c2a10e1f4ce27a08eafb70cbac09c1.jpg' is not a directory
  mv: target '7ff0671fc0447ca009d216670a0e2ac9.gif' is not a directory
  mv: target 'e27c3fe527a6417e13f2b55865b77d4f.jpg' is not a directory
  mv: target 'd32b6aa0ff3929b477fe5e33872220d1.png' is not a directory
  mv: target '70df8a56449a7b19b286e0b77394a7c8.jpg' is not a directory
  mv: target '7e9b7446ea3fe662fa7ba3ba45952cbf.jpg' is not a directory
  mv: target '975de97e64c345cbe41532101636c70e.gif' is not a directory
  mv: target 'c3a691daa3400f00c87de37703ddd222.jpg' is not a directory
  sh: 1: Syntax error: "(" unexpected
  sh: 1: Syntax error: "(" unexpected
  mv: target 'ce14ef4371c5fe6a61a539a9f22e6227.jpg' is not a directory    
  </code></pre>