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
Post a Comment