Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Rename this String- Help

$
0
0

Hi H.

You could try something like this:

Get-ChildItem -Path $sourcedir |
    foreach { 
        if ($_ -match "(\d{10})" ) {
            Rename-Item -Path $_.FullName -newName "$($matches[0])$($_.Extension)"
        }
    }

It's not pretty, but it works :)


Viewing all articles
Browse latest Browse all 13067

Trending Articles