Rename File Extension for Multiple Files at once !
Oh Snap ! what are this file extensions .. *.err , *.log
why it’s not like *.txt ? ..if i had a way replace the extension 🙂
lets do it !
first choose the relevant path –
1 |
$Getfiles = Dir C:\Workdir\*.err |
count the files ,so the script knows when to stop on the loop –
$GetFiles.Length
what’s the full name for each file you’re parsing into the loop ?
create variable to present it and if its match your request then Rename it with
Rename-Item cmdlet
change multiple file extensions on folder –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
$Getfiles = Dir C:\Workdir\*.err try{ for($i=0;$i -le $Getfiles.Length; $i++) { $filex = $Getfiles[$i] $filexfullname = $filex.fullname $filexfullname if ($filexfullname -like "*err*") { rename-item $filexfullname -NewName $filexfullname.Replace("err","txt") } } } catch{$_} |
(Visited 3,755 times, 1 visits today)