50 lines
770 B
Go
50 lines
770 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"ffmpeg.d/pkg/fs"
|
|
)
|
|
|
|
func main() {
|
|
if err := Run(context.Background(), os.Args[1:]); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func Run(ctx context.Context, args []string) error {
|
|
cams, err := lsd(args[0])
|
|
if err != nil {
|
|
return fmt.Errorf("failed to lsd %s: %w", args[0], err)
|
|
}
|
|
|
|
for _, cam := range cams {
|
|
files, err := lsf(cam)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to lsf %s: %w", cam, err)
|
|
} else if len(files) < 1 {
|
|
continue
|
|
}
|
|
|
|
for _, file := range files {
|
|
log.Println("rm", file)
|
|
if os.Getenv("DRY_RUN") == "false" {
|
|
os.Remove(file)
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func lsd(d string) ([]string, error) {
|
|
return fs.LsD(d)
|
|
}
|
|
|
|
func lsf(d string) ([]string, error) {
|
|
return fs.LsF(d)
|
|
}
|