I am using PowerShell to replace pdf file names:
Get-ChildItem -Path C:\All -Filter *.pdf | Rename-Item -NewName { $_.Name.Replace('.','_') }
It works fine if I replace %20
to _
, but if we use "test.one.pdf", I need "test_one.pdf" as output, if I use above syntax it replaces the . before pdf like "test_one_pdf".
Your code will rename name.001.pdf
to name_001_pdf
, so unless you actually want to remove the extensions of your files you need to replace only within the files name and not the extension.
Get-ChildItem -Path "C:\All" -Filter "*.pdf" | Rename-Item -NewName { $_.BaseName.Replace(".","_") + $_.Extension }
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