convert: ( .png, .jpeg, .jpg, .bmp) to: ( .webp)

Nightpresider 1 Reputation point
2022-12-07T16:41:39.633+00:00

(i ran the below script on win10 and it worked, new machine in win11 and the script is no longer working in powershell admin)

POWERSHELL SCRIPT

Convert all png/jpg/gif recursively from current directory to webp

Get-ChildItem .* -R -include *.png, *.jpg, *.jpeg, *.gif |
Foreach-Object {
$filename = "$($.FullName.split('.')[0]).webp"
if (Test-Path $filename -PathType leaf) {
echo "Skipped $
"
return
}
magick convert -strip $.FullName -quality 75 $filename
echo "Converting $
"

If ($LASTEXITCODE -eq "0") {  
del $_.FullName  
echo "Deleting $_"  
} else {  
	Write-Host "Error converting file " + $_.FullName -ForegroundColor red -BackgroundColor white  
}  

}

echo "All done!"
pause

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,623 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Hoekstra Jelle 501 Reputation points
    2023-01-18T18:05:10.14+00:00

    Have you been able to check the answer from Rich Matheisen above?

    Have you checked if magick exists on your current device?

    Perhaps with a command like this:

    Get-Command -Name "*magick*"
    
    0 comments No comments

  2. anower hossain 0 Reputation points
    2023-02-11T13:58:36.1666667+00:00

    <iframe width="640px" height="480px" src="https://forms.office.com/Pages/ResponsePage.aspx?id=DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAN__mAijG5UNDlQMkNUTDFPWFhFUVRIWUZHVkFNVVpMVi4u&embed=true" frameborder="0" marginwidth="0" marginheight="0" style="border: none; max-width:100%; max-height:100vh" allowfullscreen webkitallowfullscreen mozallowfullscreen msallowfullscreen> </iframe>

    0 comments No comments

  3. anower hossain 0 Reputation points
    2023-02-11T13:58:48.02+00:00

    <iframe width="640px" height="480px" src="https://forms.office.com/Pages/ResponsePage.aspx?id=DQSIkWdsW0yxEjajBLZtrQAAAAAAAAAAAAN__mAijG5UNDlQMkNUTDFPWFhFUVRIWUZHVkFNVVpMVi4u&embed=true" frameborder="0" marginwidth="0" marginheight="0" style="border: none; max-width:100%; max-height:100vh" allowfullscreen webkitallowfullscreen mozallowfullscreen msallowfullscreen> </iframe>

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.