func RenamePic(c *gin.Context) {
dir:="C:\\Users\\cixu\\Desktop\\100D5600-3"
// 遍历文件夹,获取文件路径
paths := make([]string, 0)
filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if !info.IsDir() {
paths = append(paths, path)
}
return nil
})
pattern:="" //重命名图片的前缀
// 遍历文件路径,修改文件名
for i, path := range paths {
newPath := filepath.Join(filepath.Dir(path), fmt.Sprintf("%s%d",pattern, i+1)+filepath.Ext(path))
os.Rename(path, newPath)
}
c.JSON(http.StatusOK,gin.H{"value":pattern})
}
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Machine Learning in Action
Peter Harrington / Manning Publications / 2012-4-19 / GBP 29.99
It's been said that data is the new "dirt"—the raw material from which and on which you build the structures of the modern world. And like dirt, data can seem like a limitless, undifferentiated mass. ......一起来看看 《Machine Learning in Action》 这本书的介绍吧!