title: Move files in a for loop
body: <p>I want a script that is able to read the content of a text file which contains folder names and moves the folders from their directory to a specific folder. Here is my script:</p>
  
  <pre><code>     #!/bin/bash
       for i in $(cat /folder/collected/folders.txt)
        do
         mv /fromfilelocation/$i /folder/Collected/
        done
  </code></pre>
  
  <p>This script is partly working as it copies only the last folder in the text file, as for the other folders it gives the error "not possible: data or directory not found" But the folder is there and according to the error the folder directory is correctly displayed.</p>
  
  <p>What should I do in order to make it work correctly ??</p>