-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvrt.go
59 lines (50 loc) · 1.3 KB
/
convrt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
)
func checkSubstrings(str string, subs ...string) bool {
isCompleteMatch := false
// fmt.Printf("String: \"%s\", Substrings: %s\n", str, subs)
for _, sub := range subs {
if strings.Contains(str, sub) {
isCompleteMatch = true
} else {
}
}
return isCompleteMatch
}
func main() {
var PATH2 string
err := filepath.Walk("C:\\mpc_samples\\DRUMMACHINES",
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !checkSubstrings(path, ".wav", ".WAV", ".jpg", ".db", ".rtf", ".aif", ".aiff", ".pdf") {
fmt.Println(path)
PATH2 = strings.Replace(path, "DRUMMACHINES", "DRUMMACHINES16bit", -1)
PATH2 = strings.Replace(PATH2, " ", "_", -1)
os.MkdirAll(PATH2, os.ModePerm)
} else {
if checkSubstrings(path, ".wav", ".WAV", ".aif", ".aiff") {
path3 := strings.Replace(path, "DRUMMACHINES", "DRUMMACHINES16bit", -1)
path3 = strings.Replace(path3, " ", "_", -1)
fmt.Println(path)
fmt.Println(path3)
cmd := exec.Command("ffmpeg.exe", "-i", path, "-c:a", "pcm_s16le", "-ar", "44100", "-stats", path3)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err = cmd.Run()
}
}
time.Sleep(1)
return nil
})
if err != nil {
}
}