I have below files in folder with a same name. Only the extensions are different. All files are valid jpg but with the wrong extension.
How to rename them with extension as .jpg, with a different prefix?
ren *.* *.jpg
----> Is not working for me as they all are having same prefix
This should work for you:
Clear-Host
$directoryPath = "C:\directory\with\images"
#Getting all files with "1.*" from $directoryPath
$foldercontent = Get-ChildItem -Path $directoryPath -Filter "1.*" | Where-Object { ! $_.PSIsContainer }
foreach($item in $foldercontent) {
Move-Item -Path $item.FullName -Destination "$directoryPath\image$($item.Extension).jpg"
}
File names will be:
image.J84.jpg
image.J85.jpg