Powershell
Код:

$file = 'C:\Temp\1.txt'
$content = gc $file |
group {$_ -replace '.*/(.+)\..+?$','$1'} |% {
if ($_.count -eq 1) {
$_.group
}
else {
if ($_.group -match 'mp4$') {($_.group -match 'mp4$')[-1]}
else {($_.group)[-1]}
}
}
Set-Content -Path $file -Value $content