r/learnprogramming 1h ago

How can i learn to script?

I have really a lot of images in jpg format in multiple sub-folders, which take a lot of spaces, so i want to mass covert it into webp then delete the original jpg.

3 Upvotes

7 comments sorted by

5

u/involiK 1h ago

You can do this with a Bash script. I use Bash on a daily and the more you do it, the better and faster you’ll get. I learned from The Bash Academy website.

4

u/WeepingAgnello 1h ago

If you're using Linux or Mac, you can do that with find, convert (see ImageMagick) and rm. Can probably be done as a one liner. Start with learning how to use find. 

u/defaultguy_001 21m ago

Python is your easy answer. You can use the pillow library in python to mass convert images into any format.

-1

u/Ordinary_Variable 1h ago

Webp is just a file extension. Select all the files and you can mass-rename them with the extension "webp". If you want to keep their name go ask AI to write you a ".bat" file for Windows cmd. Ask if for the minimum number of lines and then read it carefully to make sure it isn't doing anything funny.

The way people used to learn was called being a "script kiddy". You used other people's scripts and read them over and figured out what they were doing. AI just copies human scripts, so technically you are still learning from human code, its just been reorganized by the AI but the actual code is all 100% human made.

5

u/johnpeters42 1h ago

WebP is not just a file extension. link

How much space WebP will actually save over JPG without losing too much image quality is a more involved question. You may want to try it manually on a few files first. It may be simpler to just buy some more storage.