Another great little feature of powershell is the ability to easily rename a set of files. For example, to rename all files in a [tmpfiles] folder, and replace all spaces with a dash…
gci -Path c:\tmpfiles | rename-item -newname {$_.name -replace ” “, “-“}
could also be written
gci | %{rni $_ $_.name.Replace(” “, “-“)}
The shortcuts here are:
gci = Get-Childitem
% = ForEach-Object
rni = Rename-item
Leave a comment