title: Powershell copy directories using a csv listing
body: <p>Hey I am fairly new to PowerShell and I am trying to create a movie transfer script. I have create a script that will list the child-items from my movie folder and dump them to a .csv. The end user will then be able to select files within the .csv and place a 'y' in another column. I will then run a Powershell script to filter out their selection using the 'y' column and compare and copy-items to a separate folder/drive.</p>
  
  <p>I am having some issues with comparing the .csv with the original folder where the movies are kept and then copying them over to another folder. My script will only find and copy one array item at a time using [0] etc.</p>
  
  <p>Here is an example of my export-csv script (which works without issue) and my copy-item script (which has the issues)</p>
  
  <p><strong>EXPORT-CSV.ps1</strong></p>
  
  <pre><code>$Movies = "D:\Media\Movies"
  
  Get-ChildItem $Movies | select name,y | Export-Csv D:\Media\Media_Scripts\Movies.csv -NoTypeInformation
  </code></pre>
  
  <p>And an Image of the output .csv file</p>
  
  <p><a href="https://i.stack.imgur.com/mvGfY.png" rel="nofollow noreferrer">Movies.csv</a></p>
  
  <p><strong>COPY-ITEM.ps1</strong> Works but only when i add a single array number in [] after $csv_name. This is not ideal because I would like to recurse and copy all the selected folders to the new location</p>
  
  <pre><code>$Csv_loc = "D:\Media\Media_Scripts\"
  $Movies_loc = "D:\Media\Movies\"
  $Test = "D:\Media\Media_Scripts\Test\"
  
  $csv = Import-Csv "$csv_loc\Movies.csv" | Where-Object{$_.y -eq "y"} | select name
  
  $csv_name | foreach($_)
  { 
  Get-ChildItem $movies_loc | Where-Object {$_.Name -contains $csv_name[0]} | copy-item -Destination $Test -Recurse -Verbose
  }
  </code></pre>