This command is very useful when renaming bulk files, usually after reinstalling a server with log files. Execute this on the main directory where the files are stored. It can contain sub-directories.
PS C:\Windows\IstoyLogs> Get-ChildItem -Filter "*.0002.mml"
-Recurse | Rename-Item -NewName
{$_.name -replace ".0002.mml",".0001.mml"}
Get-ChildItem -Filter "*.0002.mml"
This specific part of the command filters all child items, or files within sub-folders that whose file type is .mml and the last 4 5 characters of the filename is “.0002”. This is actually a method of filtering files based on something common with their filenames.
-Recurse
This parameter gets all the items in the current location, and in all child items of the same location.
Rename-Item -NewName {$_.name -replace ".0002.mml",".0001.mml"}
This renames all the files ending in “.0002.mml” to “.0001.mml”.
Refer to this link for further understanding on Get-ChildItem command.