Initial
This commit is contained in:
3
go.mod
Normal file
3
go.mod
Normal file
@ -0,0 +1,3 @@
|
||||
module git.javil.eu/jacob1123/rename-journal
|
||||
|
||||
go 1.22.7
|
25
main.go
Normal file
25
main.go
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"io/fs"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dir := "/home/jacob/Notes/Journal/"
|
||||
journalRegex, err := regexp.Compile("^(\\d\\d\\d\\d)/(\\d\\d) - ([^/]*)/(\\d\\d) - ([^/]*)$")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
filepath.Walk(dir, func(path string, info fs.FileInfo, err error) error{
|
||||
path = path[len(dir):]
|
||||
matches := journalRegex.FindStringSubmatch(path)
|
||||
if len(matches) > 0 {
|
||||
fmt.Println(path)
|
||||
fmt.Println(matches[1]+"/"+matches[2]+" - "+ matches[3]+"/"+matches[1]+"-"+matches[2]+"-"+matches[4] + " - " + matches[5])
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user