Skip to content

Instantly share code, notes, and snippets.

@kumamotone
Last active November 30, 2021 01:22
Show Gist options
  • Select an option

  • Save kumamotone/245094319eff2d68fcd9900d62f09ed8 to your computer and use it in GitHub Desktop.

Select an option

Save kumamotone/245094319eff2d68fcd9900d62f09ed8 to your computer and use it in GitHub Desktop.
delete all specified signals of BBCSO
package main
import (
"bufio"
"fmt"
"io/fs"
"os"
"path/filepath"
"regexp"
"strings"
)
func main() {
args := os.Args[1:]
if len(args) < 1 {
fmt.Println("Specify abbreviations of signals.")
fmt.Println("Example: go run main.go mo01 ou01 ba01")
fmt.Println()
fmt.Println("To see all abbreviations of signals, access below.")
fmt.Println("https://spitfireaudio.zendesk.com/hc/en-us/articles/360002636258-How-to-remove-microphones-from-BBC-Symphony-Orchestra-Professional")
return
}
for i, arg := range args {
args[i] = strings.ToUpper(arg)
}
workDir, _ := os.Getwd()
findList := []string{}
err := filepath.WalkDir(workDir, func(path string, info fs.DirEntry, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
for _, arg := range args {
r := regexp.MustCompile(arg)
if r.MatchString(path) {
findList = append(findList, path)
}
}
return nil
})
if err != nil {
panic(err)
}
for _, path := range findList {
fmt.Printf("%v\n", path)
}
fmt.Println()
fmt.Println("====================")
fmt.Println()
fmt.Printf("%v items found.\n", len(findList))
fmt.Printf("Delete? (y/N) > ")
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
input := scanner.Text()
if input == "y" || input == "Y" || input == "yes" || input == "Yes" {
for _, path := range findList {
os.Remove(path)
}
} else {
fmt.Println("cancel")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment