From 5be8b7d56c292e830ad88f0c33c3276fb15a1d12 Mon Sep 17 00:00:00 2001 From: lordwelch Date: Sat, 30 Jun 2018 00:32:58 -0700 Subject: [PATCH] Fix a replacement and actually rename the file --- san.go => path.go | 2 +- {cmd => santree}/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename san.go => path.go (94%) rename {cmd => santree}/main.go (95%) diff --git a/san.go b/path.go similarity index 94% rename from san.go rename to path.go index 508f24a..f4129d2 100644 --- a/san.go +++ b/path.go @@ -20,7 +20,7 @@ func SanitizeFilename(filename string) string { filename = strings.TrimLeft(filename, " -~") filename = strings.TrimSpace(filename) filename = strings.Replace(filename, " ", "_", -1) - filename = strings.Replace(filename, "_-_", "", -1) + filename = strings.Replace(filename, "_-_", "-", -1) var ( st strings.Builder prev rune diff --git a/cmd/main.go b/santree/main.go similarity index 95% rename from cmd/main.go rename to santree/main.go index f38913e..22eae82 100644 --- a/cmd/main.go +++ b/santree/main.go @@ -28,7 +28,7 @@ func main() { if path != filepath.Join(newpath, filename) { fmt.Println(path, "->", filepath.Join(newpath, filename)) os.MkdirAll(newpath, os.ModePerm) - os.Rename(path, filepath.Join(newpath, info.Name())) + fmt.Println(os.Rename(path, filepath.Join(newpath, filename))) } if !(strings.HasPrefix(path, previousDir) || previousDir == "./") { rmpath := previousDir