Reputation: 1
I have been trying to ask PowerShell to move certain files using a CSV file to indicate where, what needs to be moved to.
Here is my script:
import-csv sample1.csv | foreach { copy-item $_.source\$_.file $_.destination\$_.file}
Here is the csv its meant to get the information from. image of the CSV of files i need to move.
Please, if anyone can help, that would be great.
Upvotes: 0
Views: 649
Reputation: 10019
What's the full error? Assume it doesn't like the fact you're not using quotes:
Import-Csv sample1.csv |
ForEach-Object {
Copy-Item -Path "$_.source\$_.file" -Destination "$_.destination\$_.file"
}
Upvotes: 1