Convert entire directory to WebP Mac OSX

982 views
Skip to first unread message

James

unread,
Sep 9, 2011, 7:47:19 PM9/9/11
to WebP Discussion
Hi,

I hope this isn't a really dumb questions, but I'm really struggling
here...

I would like to convert all .JPG in a directory to .WEBP on Mac OSX.
I'm using this command:

./cwebp ~/input/*jpg -o ~/output/*.webp

Unfortunately, all I'm getting is one converted file.

Any ideas?

Thanks in advance,

James

toby

unread,
Sep 11, 2011, 6:06:51 PM9/11/11
to WebP Discussion


On Sep 9, 7:47 pm, James <jhtaylor...@gmail.com> wrote:
> Hi,
>
> I hope this isn't a really dumb questions, but I'm really struggling
> here...
>
> I would like to convert all .JPG in a directory to .WEBP on Mac OSX.
> I'm using this command:
>
> ./cwebp ~/input/*jpg  -o ~/output/*.webp
>
> Unfortunately, all I'm getting is one converted file.

cwebp converts just one file at a time. What you want is:

for F in ~/input/*.jpg ; do cwebp $F -o ~/output/`basename ${F%.jpg}
`.webp ; done

(This assumes that filenames do not contain spaces.)

daft...@gmail.com

unread,
Nov 3, 2014, 11:49:25 AM11/3/14
to webp-d...@webmproject.org
Could you please also show how to do this on Linux?

Thanks in advance!

James Zern

unread,
Nov 4, 2014, 4:45:22 AM11/4/14
to webp-d...@webmproject.org, daft...@gmail.com
Hi,


On Monday, November 3, 2014 5:49:25 PM UTC+1, daft...@gmail.com wrote:
Could you please also show how to do this on Linux?


The shell for loop earlier in the thread will work under Linux or any shell interpreter. The dependency on basename could be removed, but it should generally be available.
For convenience:
for F in ~/input/*.jpg ; do cwebp $F -o ~/output/`basename ${F%.jpg}`.webp ; done 
 
Thanks in advance!
Reply all
Reply to author
Forward
0 new messages