Powershell rename files

Rename Files with Special character in name

$pattern1 = "#"
$pattern2 = "%"
$path = "E:\data\"
Switch(Get-ChildItem -Path $path -recurse){
    {$_.Name -match $pattern1}{$new_name = $_.Name -replace $pattern1, ""
        Rename-Item -Path $_.FullName -NewName $new_name}
Switch(Get-ChildItem -Path $path -recurse){
    {$_.Name -match $pattern2}{$new_name = $_.Name -replace $pattern2, ""
        Rename-Item -Path $_.FullName -NewName $new_name}
}

You may also like...