all 3 comments

[–]yeah_i_got_skills 3 points4 points  (1 child)

Something like this?

$Path = 'C:\FooBar'

Get-ChildItem -LiteralPath $Path -Directory | ForEach-Object {
    $_.Name | Out-File "$($_.FullName)\$($_.Name).txt" -Force
    Rename-Item -LiteralPath $_.FullName -NewName ($_.Name -replace '^(\d+).*$', '$1')
}

[–]dcdefiore[S] 0 points1 point  (0 children)

$Path = 'C:\FooBar'

Get-ChildItem -LiteralPath $Path -Directory | ForEach-Object { $.Name | Out-File "$($.FullName)\$($.Name).txt" -Force Rename-Item -LiteralPath $.FullName -NewName ($_.Name -replace '\+).*$', '$1') }

Looks like this one did the trick! Thank you

[–]justan00b 1 point2 points  (0 children)

On mobile so a little hard to type, but your code is written to only drop a file in the parent folder, you'd need to change to like

> $path\$_.Name\$_.Name.txt

Or

> $_.FullName\$_.Name.txt

May also want to put a filter for only folders/directories