So I was redownloading my google drive backup and I noticed that in every file no matter how deep in my directory and or subdirectory it had in its name a "(1)" and I was wondering about removing this.
Iv gotten to get-childitem . | foreach { rename-item $_ $_.Name.Replace(" (1)", "") }
but thats only for this directory and I need to go deeper a lot deeper.
Thanks in advance.
update: got to "get-childitem -recurse | rename-item -newname { $_.name -replace " (1)", ""}" however it throws an error: rename-item : Source and destination path must be different. At line:1 char:26
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
edit: Get-ChildItem -Path "C:\My\Root\Path" -Filter "(1)" -Recurse | Foreach {Rename-Item -Path $.FullName -NewName $.Name.Replace('(1)','')} ^ this is what worked for me
How about this?
Get-ChildItem -Path "C:\My\Root\Path" -Recurse | Foreach {Rename-Item -Path $_.FullName -NewName $_.Name.Replace('(1)','')}