Fix a replacement and actually rename the file
This commit is contained in:
parent
9469379b80
commit
5be8b7d56c
@ -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
|
@ -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
|
Loading…
Reference in New Issue
Block a user