SHARE
TWEET

Untitled

a guest Feb 17th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "io/ioutil"
  6.     "log"
  7.     "os"
  8.     "path/filepath"
  9.     "strconv"
  10. )
  11.  
  12. func main() {
  13.     files, err := ioutil.ReadDir("./originals")
  14.     if err != nil {
  15.         log.Fatal(err)
  16.     }
  17.  
  18.     for i, file := range files {
  19.         // Get original extension
  20.         ext := filepath.Ext("./originals/"+file.Name())
  21.  
  22.         // This function moves file instead of copying
  23.         os.Rename("./originals/"+file.Name(), "./originals/photo_"+strconv.Itoa(i)+ext)
  24.     }
  25.  
  26.     // Inform about being done
  27.     fmt.Println("DONE")
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top