Static site generator for making web mixtapes in 2020.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

39 linhas
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. }