Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 Windows 10 上使用 cmd。
我想将文件复制day_template.md到day2.md, day3.md, ..,dayN.md
day_template.md
day2.md
day3.md
dayN.md
使用此名称模式创建多个副本的命令是什么。我需要一些增量器来制作每一天{i}.md,其中 i 由我指定。
检查文件是否存在也很好。例如,我手动创建day1.md
day1.md
希望问题很清楚。
您可以将这些命令写入cmd.exe命令提示符
cmd.exe
for /l %x in (1, 1, N) do ( if not exist day%x.md ( copy day_template.md day%x.md ) )
其中N是您要制作的文件的最大副本数。如果您想将此代码嵌入到批处理脚本中,请使用%%代替%,即
N
%%
%
for /l %%x in (1, 1, N) do ( if not exist day%%x.md ( copy day_template.md day%%x.md ) )