Skip to content

Instantly share code, notes, and snippets.

@iampato
Last active March 22, 2021 07:01
Show Gist options
  • Select an option

  • Save iampato/d51f5e4f3ed458bbd9f3377bcf3ff51c to your computer and use it in GitHub Desktop.

Select an option

Save iampato/d51f5e4f3ed458bbd9f3377bcf3ff51c to your computer and use it in GitHub Desktop.
Calling os.exec on some files
package main
import (
"fmt"
"io/ioutil"
"log"
"strings"
"os/exec"
)
const dir = "/home/pato/Desktop/icons/"
func main() {
files, err := ioutil.ReadDir(dir)
if err != nil {
log.Fatal(err)
}
for _, file := range files {
if strings.Contains(file.Name(), ".go") {
}else {
cmd := exec.Command("/home/pato/Software/svgcleaner/svgcleaner",dir+file.Name(),dir+"new"+file.Name())
err := cmd.Run()
fmt.Println("Finished:", err)
fmt.Println(file.Name())
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment