I am lost with simple rename-item. Need to remove string contents from title of subfolders and rename the object (i.e. remove [4K]
). I tried but I’m getting a “Rename-item: Cannot rename because item at … does not exist”. Sorry for dumb question but I’m trying to learn Powershell.
$path = "E:\test data"
Get-ChildItem $path -Directory | Foreach-Object {
$file = $_.Fullname
$file = $file -replace ('4K','')
Write-Output $file
Rename-Item -Path $_.Fullname -NewName $file
Get-ChildItem "E:\test data"
}