I currently have a script that will loop through a group of files in a folder - open each one up and let me enter a new file name and then rename it. I am then trying to create a CSV file with the old name in one column and the new name of the file in the second column.
#[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
Add-Type -AssemblyName Microsoft.VisualBasic
$folderpath = 'C:\Scans\docs\' '#
$items = Get-ChildItem -Recurse $folderpath *.pdf
$newFileName = ""
$counterID = 0
$amountOfScans = $items.Length
foreach( $i in $items) {
Start-Process ((Resolve-Path ("$folderpath$i")).Path)
Start-Sleep -Seconds 1
$counterID++
$newFileName = [Microsoft.VisualBasic.Interaction]::InputBox("Enter the new file name $counterID / $amountOfScans :", $i)
Stop-Process -Name "Acro*"
Add-Content -Path 'C:\Scans\fileNames.csv' -Value "$i","$newFileName "
Rename-Item $i.FullName ("$newName.pdf")
}
This does work but it outputs into the csv only in the first column like:
old file name 1 new file name 1 old file name 2 new file name 2
How do make this output:
old file name 1 | new file name 1 old file name 2 | new file name 2