Directory with a number of files and subdirectories: I need to move those files into each subdirectories,as per file name in Ruby
<p>I have one directory with a number of files and subdirectories. I need to move those files into each subdirectories, depending on their naming. For instance:</p>

<p>Files:</p>

<pre><code>Hello.doc
Hello.txt
Hello.xls
This_is_a_test.doc
This_is_a_test.txt
This_is_a_test.xls
Another_file_to_move.ppt
Another_file_to_move.indd
</code></pre>

<p>Subdirectories:</p>

<pre><code>Folder 01 - Hello
Folder 02 - This_is_a_test
Folder 03 - Another_file_to_move
</code></pre>

<p>What I need is to move the three files named <code>Hello</code> into folder <code>Folder 01 - Hello</code>; the three files called <code>This_is_a_test</code> into directory <code>Folder 02 - This_is_a_test</code> and the two files named <code>Another_file_to_move</code> into directory called <code>Folder 03 - Another_file_to_move</code>. I have hundreds of files, not just these ones.</p>

<p>As it can be seen, the folder name contain the name of the file at the end, but at the beginning there is a <code>Folder</code> + <code>\s</code> + a <code>number</code> + <code>\s</code> + a <code>-</code>. This is a global pattern. </p>

<p>Any help?</p>