Answer the question
In order to leave comments, you need to log in
PowerShell does not execute the -newname command if there are spaces in the path, what should I do?
In case of command execution
dir -Recurse "D:\VideoArchive\Instagram\*qwer*" | ren -newname {$_.name.replace("qwer", "")}
dir -Recurse "D:\Instagram\курс по продвижению\*qwer*" | ren -newname {$_.name.replace("qwer", "")}
dir -Recurse "D:\Instagram\курс` по` продвижению\*qwer*" | ren -newname {$_.name.replace("qwer", "")}
dir -Recurse "& 'D:\Instagram\курс по продвижению\*qwer*'" | ren -newname {$_.name.replace("qwer", "")}
dir -Recurse "& 'D:\Instagram\курс по продвижению\*qwer*'" | Invoke-Expression | ren -newname {$_.name.replace("qwer", "")}
dir -Recurse "*qwer*" | ren -newname {$_.name.replace("qwer", "")}
but I want more automation and fewer clicks :-)
Answer the question
In order to leave comments, you need to log in
Try
$items = Get-childItem -Path "D:\Instagram\курс по продвижению\*qwer*" -Recurse -Force
foreach($item in $items) {
Rename-Item -Path $item -NewName $item.Name.Replace("qwer", "")
}
Get-childItem -Path "D:\Instagram\курс по продвижению\*qwer*" -Recurse -Force | % Rename-Item -NewName {$_.Name.Replace("qwer"m "")}
You are not saying something :)
because it normally renames everything even without wrappers around Rename-Item ,
rename can get its -Path through the pipeline, and -newname you have just tested the
script.
Even inside a folder renamed in the process, renames the contents
Add to the original ren -whaitif and see what it produces
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question