26 lines
591 B
Go
26 lines
591 B
Go
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
|
|
})
|
|
}
|