I have the following code:
Get-ChildItem . *. | Rename-Item -NewName {$_.Name -replace 'line21','line21.map52'}
producing this error:
file: line21 is currently of type File (No extension).
When trying to change it to another extension it does not change.
However for the same scenario, it works perfectly fine if I took another file:
Get-ChildItem . *. | Rename-Item -NewName {$_.Name -replace 'line22.txt','line22.map52'}
This behavior is happening, because your Get-ChildItem
command is only retrieving files/folders whose names match *.
. The file name "line21" does not match *.
so it is being excluded.
Change your command to this:
Get-ChildItem -Path . -Include * | Rename-Item -NewName {$_.Name -replace 'line21','line21.map52'};