Batch delete duplicate words in file name the code is posted in the this post, but it does not work with me Deleting repeated parts of a file name?
Get-ChildItem -Path .\* -File -Recurse | ForEach-Object {
Rename-Item $_ -NewName ((($_.Basename.Split("_") | Select-Object -Unique) -Join "_") + $($_.Extension))
}
(Get-ChildItem -Path .\* -File -Recurse) | Rename-Item -NewName { (@($_.BaseName.Split('_') | select -unique) -join '_') + $_.Extension } -WhatIf. – Keith Miller Feb 25 '23 at 10:50-
-
- CategoryInfo : InvalidOperation: (:) [Rename-Item], PSInvalidOperationException
- FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.RenameItemCommand
– m26348762 Feb 25 '23 at 21:38