This language bar is your friend. Select your favorite languages!

Idiom #177 Find files with a given list of filename extensions

Construct a list L that contains all filenames that have the extension ".jpg" , ".jpeg" or ".png" in directory D and all it's subdirectories.

L = Dir.glob(File.join("**", "*.{jpg,jpeg,png}"), base: D)
import "path/filepath"
import "strings"
L := []string{}
err := filepath.Walk(D, func(path string, info os.FileInfo, err error) error {
	if err != nil {
		fmt.Printf("failure accessing a path %q: %v\n", path, err)
		return err
	}
	for _, ext := range []string{".jpg", ".jpeg", ".png"} {
		if strings.HasSuffix(path, ext) {
			L = append(L, path)
			break
		}
	}
	return nil
})
FileUtil
L := FindAllFiles(D, '*.jpg;*.jpeg;*.png', True);

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Bart