windows - 在 Windows 中批量重命名多个文件?

标签 windows file batch-file renaming

我想知道我的编码有什么问题,因为它不起作用

我想重命名 Chris 中的所有 png 文件。

但是失败了

for /f  in ('C:/Users/Chris/Downloads/images/*.png')
 do ren "C:\Users\Chris\Downloads\images\*.png" "%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%-img.png"

最佳答案

参数中不需要/f,不需要引号,但缺少变量声明

变量应该在 do 部分使用,否则 for 没有什么用

for 将枚举完整路径,因此您需要使用 ~n 去除文件名

do部分必须直接在for语句后面或者需要在圆括号内

完整代码如下:

for %%i  in (C:/Users/Chris/Downloads/images/*.png) do (
   ren "%%i" "%date:~10,4%-%date:~4,2%-%date:~7,2%_%HR%%time:~3,2%-%%~niimg.png"
)

关于windows - 在 Windows 中批量重命名多个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29505619/

相关文章:

java - SSL Socket OutputStream Write Slow only on Windows

c++ - 'strcpy' 和 'strcpy_s' 之间的区别?

c - 错误的文件描述符

python - 迭代多个生成器(文件句柄)

windows - 为什么出现 “Insert the diskette that contains the batch file and press any key when ready.”消息?

windows - 处理文件名中的特殊字符时批量重命名问题

windows - 更新Windows文件夹中的所有git repos

css - 使用图像作为输入文件显示输入类型文件中的图像文件名

windows - 如何使用批处理文件在静默安装期间阻止窗口退出?

windows - for 循环和定界符