Skip to content

Instantly share code, notes, and snippets.

@matijagrcic
Created November 18, 2016 18:28
Show Gist options
  • Save matijagrcic/c28319b22e2ffffad366c3e00ae7b5aa to your computer and use it in GitHub Desktop.
Save matijagrcic/c28319b22e2ffffad366c3e00ae7b5aa to your computer and use it in GitHub Desktop.
Batch convert webp to png
#Download dwebp (WebP decoder tool) https://developers.google.com/speed/webp/download
#Run
for %f in (*.webp) do dwebp.exe "%f" -o "%~nf.png"
@chokychou
Copy link

Under rated code. Thank you!

@scr2em
Copy link

scr2em commented Nov 16, 2020

life saver

@PIRATAONE
Copy link

This is what works for me in a Windows batch file:

for %%f in (*.webp) do dwebp.exe -o "%%~nf.png" "%%f"

EnJoY ;-P

@aeboi80
Copy link

aeboi80 commented Dec 2, 2020

A true life saver. I just had to convert 300 images.

@HAlafeefi
Copy link

HAlafeefi commented Feb 23, 2021

is there a way to remove the original files automatically?

@geekybuilder
Copy link

How to run this code? Do you have to save the image files in the same directory?

@mheland
Copy link

mheland commented May 20, 2021

Thank you, using ZSH with for f in *.webp; do dwebp $f -o $f:r.png; done where $f:r strips the filetype

@mysticaltech
Copy link

@mheland thank you!!!

@haleyngonadi
Copy link

Thank you, using ZSH with for f in *.webp; do dwebp $f -o $f:r.png; done where $f:r strips the filetype

This worked for me! Thank you!

@yungztr
Copy link

yungztr commented Dec 7, 2022

best program ive encountered in the last years thank you very much

@annsilin
Copy link

is there a way to remove the original files automatically?

for %%f in (*.webp) do (
    dwebp.exe -o "%%~nf.png" "%%f"
    del "%%f"
)

@iBelow
Copy link

iBelow commented Jan 12, 2024

Powershell
Get-ChildItem -Filter *.webp | ForEach-Object { & '.\dwebp.exe' $_.FullName -o "$($_.BaseName).png" }

@spenceryonce
Copy link

little batch file I made for the community here:
https://gist.github.com/spenceryonce/e849800e7d7fcbb8645431f7f8abaa81

image

@spenceryonce
Copy link

is there a way to remove the original files automatically?

for %%f in (*.webp) do (
    dwebp.exe -o "%%~nf.png" "%%f"
    del "%%f"
)
@echo off
setlocal

REM Convert all WEBP files to PNG and then delete the WEBP files
for %%f in (*.webp) do (
    echo Converting %%f...
    dwebp.exe "%%f" -o "%%~nf.png"
    if errorlevel 1 (
        echo Failed to convert %%f
    ) else (
        del "%%f"
        echo Deleted %%f
    )
)

echo Conversion complete.
pause

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment