Files
2026-09-06 20:33:15 +02:00

57 lines
905 B
Go

package main
import (
"fmt"
"io/fs"
"log"
"media-converter/convertVideo"
"media-converter/optimizeImage"
"path/filepath"
"strings"
"sync"
)
var imageExts = map[string]bool{
".jpeg": true,
".jpg": true,
".png": true,
".gif": true,
".bmp": true,
".tiff": true,
".tif": true,
".webp": true,
}
var wg sync.WaitGroup
func main() {
err := filepath.WalkDir(".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
ext := strings.ToLower(filepath.Ext(path))
switch {
case ext == ".mov":
wg.Go(func() {
convertVideo.ConvertVideo(path)
})
case imageExts[ext]:
if optimizeImage.Touched[path] {
fmt.Printf("Skipping %s (already touched)\n", path)
return nil
}
wg.Go(func() { optimizeImage.OptimizeImage(path) })
}
return nil
})
wg.Wait()
if err != nil {
log.Fatal(err)
}
}