title: Powershell script to create folders from list of names in a file
body: <p>I have a text file that contains a list of files in different directories, e.g</p>
  
  <ul>
  <li><code>C:\FolderOne\Testing.jpg</code></li>
  <li><code>C:\FolderTwo\Test.jpg</code></li>
  </ul>
  
  <p>I'd like to turn those names into folders. And if two files exist in one folder, e.g <code>FolderOne</code>, then both those files should go into the same folder. </p>
  
  <p>I understand that the backslashes will also have to be replaced by underscores and the colon replaced by an underscore too.</p>
  
  <p>Thus far, I'm able to get the contents from the file list and copy it into a specified folder. I would like to create a folder for each file in the file list, but the folder name needs to include <code>C_FolderOne</code> and <code>C_FolderTwo</code> and so on....</p>
  
  <p>Any help would be appreciated!</p>
  
  <p>What I have so far:</p>
  
  <pre><code>Param (
      [String]$model
  )
  
  # Debug line
  $model = "DEV2";
  
  [String]$drive = "C:";
  
  #Go to the PG_dump directory
  CD "C:\Program Files\PostgreSQL\9.4\bin"
  
  ##Execute PG_dump with no password
  .\pg_dump.exe --host localhost --port 5432 --username "postgres" --role "postgres" --no-password  --format custom --blobs --verbose --file     "C:\Test\$date-DEV-$X.backup" "DEV"
  
  #Get the content from the file list
  $file_list = Get-Content "$drive\Testing\DEV33.txt" 
  foreach ($file in $file_list)
  {    
      Copy-Item  $file -Destination "C:\Testing"
  }
  </code></pre>