You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
901 B

10 months ago
package main
import (
"fmt"
10 months ago
"log"
"os"
"git.neveris.one/gryffyn/exren/parser"
. "github.com/logrusorgru/aurora/v3"
"github.com/urfave/cli/v2"
10 months ago
)
func Run() {
var format string
app := &cli.App{
Name: "exren",
Version: "v0.1.3",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "format",
Aliases: []string{"f"},
Usage: "Output format, including extension",
Destination: &format,
Required: true,
},
},
Action: func(c *cli.Context) error {
err := rename(format, c.Args().Get(0))
return err
},
}
err := app.Run(os.Args)
10 months ago
if err != nil {
log.Fatal(err)
}
}
func rename(format, path string) error {
exifData := parser.NewExif(path)
_ = exifData.Parse()
newpath := parser.ParseFormat(format, exifData.Tags)
fmt.Println(Bold(Green("✓")), Bold("Renamed to:"), newpath)
return os.Rename(path, newpath)
}
func main() {
Run()
}