Rename part of file name

Remove character from filename

The below script finds “$” within the filename and removes it while leaving the file extension intact.

Get-Item * | ForEach-Object { rename-item $_ ($_.Name -replace ‘\$’, ”) }

For our use we had a bunch of dos Professional Write files that had random file extensions that needed to be merged with file name for example test.hello. So the script below looks for “.” and removes the period so essentially the new file name becomes testhello. Notice the different between the powershell script above and below. This does not contain .Name and the characther its searching for is “.” instead of “$”

Get-Item * | ForEach-Object { rename-item $_ ($_ -replace ‘\.’, ”) }

Comments are closed.