-
-
Save agorman/6ef72d4be151326e39de980247c6ea46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"path/filepath" | |
"syscall" | |
"github.com/barasher/go-exiftool" | |
) | |
func main() { | |
dir := os.Args[1] | |
et, err := exiftool.NewExiftool() | |
if err != nil { | |
panic(err) | |
} | |
go runExiftool(dir, et) | |
sig := make(chan os.Signal, 1) | |
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) | |
<-sig | |
et.Close() | |
} | |
func runExiftool(dir string, et *exiftool.Exiftool) { | |
list, err := os.ReadDir(dir) | |
if err != nil { | |
panic(err) | |
} | |
for _, fi := range list { | |
fileInfos := et.ExtractMetadata(filepath.Join(dir, fi.Name())) | |
for _, fileInfo := range fileInfos { | |
if fileInfo.Err != nil { | |
fmt.Printf("Error concerning %v: %v\n", fileInfo.File, fileInfo.Err) | |
continue | |
} | |
for k, v := range fileInfo.Fields { | |
fmt.Printf("[%v] %v\n", k, v) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment