[string]$FileName="E:\test11" #-------------------------------------- Clear-Host foreach($f in Get-ChildItem -Path $FileName -Recurse) { if($f.Attributes -eq "Archive") { $OldName=$f.get_FullName() $NewName=$f.get_Directory().Name+"."+$f.Name.Split(".")[-2]+"."+$f.Name.Split(".")[-1] Rename-Item -Path $OldName -NewName $NewName write-host $OldName " --> " $NewName } }