batch-file - Windows 批处理文件,用于制作单个文件的多个副本,每个副本都被分配一个唯一的文件名

标签 batch-file

我正在试验 XCOPY 和各种开关命令,试图创建一个 Windows 批处理文件来制作单个图像文件的多个(一组)副本。

我想:
命名要复制的文件;
说明所需的副本数量;
为文件的每个副本分配一个唯一的文件名。 (例如原始文件 0001.png,副本 0001-2.png、0001-3.png 等)

我非常感谢这方面的帮助,因为我的脚本知识有限。谢谢。

最佳答案

for /l %A in (1,1,100) do copy "C:\some folder\file.ext" "C:\some folder\file-%A.ext"

for /?
在批处理文件中使用 %%A而不是 %A在命令提示符下。
FOR /L %variable IN (start,step,end) DO command [command-parameters]

The set is a sequence of numbers from start to end, by step amount.
So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
generate the sequence (5 4 3 2 1)

关于batch-file - Windows 批处理文件,用于制作单个文件的多个副本,每个副本都被分配一个唯一的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25293670/

相关文章:

windows-7 - Batch ~dp0 不适用于管理员权限?

Windows 批处理文件 - 按修改和/或创建日期将文件排序到文件夹中

batch-file - 批命令输入菜单

java - 从批处理文件发出运行 java 程序,在 IDE 中运行良好

batch-file - 调用后关闭浏览器

python - 批量或 python 备份/复制整个文件夹树?

用于将文件复制到文件夹的 Windows 批处理脚本

batch-file - 通过批处理脚本将具有相对路径的文件列表写入文件

command-line - 批处理文件中的字符串替换

powershell - 从另一个 .bat 调用多个 .bat 而不等待一个完成