有没有办法在Windows中使用自己的命令提示符( cmd.exe
)或terminal模拟器来创build多个文件,就像下面简单的一个class轮在任何类Unix系统中所做的一样? 请注意,我正在谈论的情况是,我无法使用任何其他terminal模拟器,如PowerShell或Win 32端口的GNU utils 。
for i in `seq 10` ; do `touch $i.txt`; done
for /l %a in (1 1 10) do type nul > "%a.txt"
对于从1到1的顺序中的每个值,使用序列中的值作为文件名( for
replaceable参数中的值),创建( >
重定向)空文件( type nul
什么都不读也不写)
该命令被写入从命令行使用。 在批处理文件中,百分号需要被转义(加倍),用%%a
替换%a
%%a
使用Windows语法:
for %A in (1 2 3) do type nul > file%A.txt
要么
for %A in (1 2 3) do echo.> file%A.txt
要么
for %A in (1 2 3) do copy nul > file%A.txt