how to use windows powershell to clean up (rename) filenames WITHOUT changing the file extention? -


on similar question on here found example of powershell script renames or better "replaces charakters" within many filenames @ once. might happen file extention itself, no good.

so how can transform example still renames filenames, leaves file extention untouched ?

here example replace dots within filename underscore:

dir | rename-item -newname { $_.name -replace "\.","_" } 

and question is: how fix not replacing last dot (file extention) ?

you can access filename minus extension basename property, can combine below:

get-childitem | rename-item -newname { "$($_.basename -replace '\.','_')$($_.extension)" } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -