I'm systematically renaming a bunch of files via PowerShell 2, and I want to output old and new filemappings to a tab-delimited output file in UTF-8. The problem is that Export-Csv (and other output methods) force a BOM to the beginning of that tsv file and breaks the output, stopping items from being properly tab-delimited and just jamming everything into the first column. I suppose if I could suppress the BOM this issue would be fixed, but any other recommendations are welcome. Code below.
Set-Location -Path ""
$destLoc = ""
$countRef = [ref] 0
Get-ChildItem -Filter *.pdf -Recurse | ForEach-Object {
$newFullName = '{0}\{1}.pdf' -f $destLoc, ++$countRef.Value
Copy-Item -LiteralPath $_.FullName -Destination $newFullName
New-Object PSCustomObject -Property @{
Old = $_.FullName
New = $newFullName
}
} | Export-Csv -Delimiter "`t" -Encoding UTF8 NameMappings.tsv