I created a basic Powershell script that has a simple objective :
- copy all files from a folder to another folder
- remove BOM from those files
- rename files
For this I created a simple script :
# input & ouput folders
$inputFolder = 'C:\Users\myName\myInputFolder'
$outputFolder = 'C:\Users\myName\myOutputFolder'
# move files
Copy-item -Force -Recurse -Verbose $inputFolder\* -Destination $outputFolder
# remove bom to files
Get-ChildItem $outputFolder\* -recurse -Include *.json,*.html,*.xml,*.js,*.txt,*.css | ForEach-Object {
$content = $_ | Get-Content
Set-Content -PassThru $_.Fullname $content -Encoding UTF8 -Force
}
# rename files
Get-ChildItem -Path $outputFolder\*.txt | Rename-Item -NewName { $_.Name -replace '.txt','.done.txt' }
My question is how to check if that I correctly removed the BOM from those files.