I have many files in a folder with this format
constant_blah_blah_blah.png
How can I replace the underscores with spaces and also remove the constant_ from them using PowerShell?
Thanks in advance.
# gather all files that match the criteria
Get-ChildItem constant_* |
ForEach-Object {
# remove the "constant_" from the beginning and replace _ by space.
Rename-Item $_ ($_.Name -replace '^constant_' -replace '_', ' ')
}
Or shorter:
ls constant_* | %{rni $_ ($_.Name -replace '^constant_' -replace '_', ' ')}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With