How can I loop through a list of files, perform an operation and save the file to a new location with a name from a list?
As an example I have a list of CSV files, and a list of new names, I would like to do a simple operation on the CSV file like changing the delimiter and save each file to a new location with a new name from the list of names. How can I set the save path and new name correctly?
$files = Get-ChildItem C:\folder\*.csv
$te = Import-Csv C:\names.csv
For ($i=0; $i -lt $te.Length;$i++){
Import-Csv $file -Delimiter "|" | Export-Csv -Path C:\another_folder\$te[$i].csv -Delimiter ","
}
To be precise, the problem is that the save path after the -Path statement is incorrect. How do I fix this?