Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "io/ioutil"
- "log"
- "os"
- "path/filepath"
- "strconv"
- )
- func main() {
- files, err := ioutil.ReadDir("./originals")
- if err != nil {
- log.Fatal(err)
- }
- for i, file := range files {
- // Get original extension
- ext := filepath.Ext("./originals/"+file.Name())
- // This function moves file instead of copying
- os.Rename("./originals/"+file.Name(), "./originals/photo_"+strconv.Itoa(i)+ext)
- }
- // Inform about being done
- fmt.Println("DONE")
- }
Add Comment
Please, Sign In to add comment