package main import ( "fmt" "io/ioutil" "log" "os" ) func main() { path := "C:\\Users\\Administrator\\Downloads\\实用go语言学习" files, err := ioutil.ReadDir(path) if err != nil { log.Fatal(err) } for index, f := range files { fmt.Println(f.Name()) os.Rename(path +"\\" + f.Name(), path +"\\" + fmt.Sprintf("实用go语言学习%02d.html", index)) } }
有疑问加站长微信联系(非本文作者)