fixstmt

Tool to rename bank statements to yyyy-mm-dd format
git clone https://git.bracken.jp/fixstmt.git
Log | Files | Refs | LICENSE

main.go (525B)


      1 // CLI tool to rename all financial statement PDFs in the current directory to
      2 // YYYY-MM-DD.pdf format.
      3 package main
      4 
      5 import (
      6 	"io/ioutil"
      7 	"log"
      8 	"os"
      9 
     10 	"git.bracken.jp/fixstmt/convert"
     11 )
     12 
     13 func main() {
     14 	files, err := ioutil.ReadDir("./")
     15 	if err != nil {
     16 		log.Fatal(err)
     17 	}
     18 	for _, f := range files {
     19 		converter, err := convert.ConverterForFile(f.Name())
     20 		if err != nil {
     21 			log.Fatal(err)
     22 		}
     23 		newFname, err := converter.Convert(f.Name())
     24 		if err != nil {
     25 			log.Fatal(err)
     26 		}
     27 		os.Rename(f.Name(), newFname)
     28 	}
     29 }