Static site generator for making web mixtapes in 2020.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

39 lignes
703 B

  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "path/filepath"
  6. "strings"
  7. "github.com/thebaer/cdr"
  8. "github.com/urfave/cli"
  9. )
  10. var cmdClean = cli.Command{
  11. Name: "clean",
  12. Usage: "clean and organize audio files in the current directory",
  13. Action: cleanAction,
  14. }
  15. func cleanAction(c *cli.Context) error {
  16. wd, err := os.Getwd()
  17. if err != nil {
  18. return err
  19. }
  20. filepath.Walk(wd, func(path string, i os.FileInfo, err error) error {
  21. if !i.IsDir() && !strings.HasPrefix(i.Name(), ".") {
  22. fName := i.Name()
  23. trackName := cdr.RenameTrack(fName)
  24. if trackName == "" {
  25. return nil
  26. }
  27. fmt.Println("Renaming", fName, "to", trackName)
  28. os.Rename(fName, trackName)
  29. }
  30. return nil
  31. })
  32. return nil
  33. }