Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

spenceryonce
spenceryonce

Posted on • Edited on

     

Automate WEBP To PNG With A Simple .Bat File

Automate Your Image Conversion with a Simple Batch Script

Managing different file formats efficiently is crucial in various development projects, from web development to organizing personal media. To streamline this task, I've developed a handy batch script that automates the conversion of WEBP images to PNG or PPM formats. This script was inspired by a discussion I came across on a GitHub Gist thread, highlighting the need for a reusable, effective solution.

Inspiration Behind This Tool

The idea for this script originated from a GitHub Gist conversation where developers shared their struggles with converting WEBP files usingdwebp.exe. Most solutions were temporary fixes rather than sustainable ones. Reminded of the user-friendly philosophy behind my previous project, VSGraph, I set out to craft a tool that would handle batch conversions and clean up afterward efficiently.

What the Script Does

Usingdwebp.exe from Google's WebP toolkit, this script efficiently converts WEBP images into PNG or PPM formats and offers an option to automatically delete the original files after conversion. It is designed to:

  1. Detect and Convert Images Automatically: It locates all.webp files in the execution directory and converts them to the specified format.
  2. Manage Clean-Up Effectively: After conversion, it can remove the original.webp files to save space and keep the directory tidy.

How to Use the Script

Setup

  1. Downloaddwebp.exe: Download this executable from Google atWebP Download.
  2. Prepare Your Script Environment: Placedwebp.exe in the same directory as your WEBP files or a globally accessible directory included in your system's PATH.

Using the Script

  1. Create the Script: Write your own script using the guidelines below or download the full script from my GitHub Gist.
  2. Run the Script: Navigate to your image directory in the command prompt and typeconvert_webp.bat for PNG output orconvert_webp.bat -ppm for PPM output.
@echooffsetlocalREM Convert all WEBP files to PNG or PPM and then delete the WEBP filesfor%%fin(*.webp)do(echoConverting%%f...dwebp.exe"%%f"-o"%%~nf.png"iferrorlevel1(echoFailedtoconvert%%f)else(del"%%f"echoDeleted%%f))echoConversioncomplete.pause
Enter fullscreen modeExit fullscreen mode

Get the Full Script

If you prefer not to build the script yourself or want to see the full implementation, you can find it on my GitHub Gist. Simply visit this link to view or download the complete script:Convert WEBP to PNG/PPM Batch Script.

How It Works

Like connecting nodes in VSGraph, this script uses simple loops and conditions to manage file conversions. It's designed to be accessible and easy to use, just like a visual shader graph editor.

What’s Next?

You tell me! This is fully open-source code and would love to see what the community does with it.

If you have suggestions for improvements or additional features, or if you've found creative ways to use this tool, please share your thoughts in the comments below!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

GLSL | Shaders | Math | Javascript | Pythonwriting mainly about these topics. 26 years old.
  • Location
    tulsa, ok
  • Work
    Founder/CTO at NovaLynx
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp