Fix a replacement and actually rename the file

This commit is contained in:
lordwelch 2018-06-30 00:32:58 -07:00
parent 9469379b80
commit 5be8b7d56c
2 changed files with 2 additions and 2 deletions

View File

@ -20,7 +20,7 @@ func SanitizeFilename(filename string) string {
filename = strings.TrimLeft(filename, " -~") filename = strings.TrimLeft(filename, " -~")
filename = strings.TrimSpace(filename) filename = strings.TrimSpace(filename)
filename = strings.Replace(filename, " ", "_", -1) filename = strings.Replace(filename, " ", "_", -1)
filename = strings.Replace(filename, "_-_", "", -1) filename = strings.Replace(filename, "_-_", "-", -1)
var ( var (
st strings.Builder st strings.Builder
prev rune prev rune

View File

@ -28,7 +28,7 @@ func main() {
if path != filepath.Join(newpath, filename) { if path != filepath.Join(newpath, filename) {
fmt.Println(path, "->", filepath.Join(newpath, filename)) fmt.Println(path, "->", filepath.Join(newpath, filename))
os.MkdirAll(newpath, os.ModePerm) 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 == "./") { if !(strings.HasPrefix(path, previousDir) || previousDir == "./") {
rmpath := previousDir rmpath := previousDir