I got stuck at some point. Assuming following directory:
d:\example
0 test1_123.txt
<DIR> test1_123_abc0
0 test2.txt
<DIR> test2_123
<DIR> test3_123_abc1
<DIR> test4_test0_abc0
I want now to remove the postfix using regex '_abc*' of all directory names. I tried the following:
Get-ChildItem d:\example\ -Directory | foreach { rename-item $_ $_ -replace '_abc.' }
Does anybody know whats wrong here and can share the solution?
Get-ChildItem 'd:\example\' -Recurse -Filter *_abc* | Rename-Item -NewName { $_.name -replace '_abc\d*$', ''}{ rename-item $_ $_ -replace '_abc.' }<<< means? have you tested it? [grin] those two$_items look oh-so-very-wrong ...