从命令行这有效:
for /d %a in (*) do copy test.bat "%a"
如果您计划将其用于批处理文件,请使用 double %%a
在批处理文件中将自身复制到所有子文件夹中
@echo off
for /d %%a in (*) do copy "%~n0%~x0" "%%a"
从help for命令:
FOR /D %variable IN (set) DO command [command-parameters]
If set contains wildcards, then specifies to match against directory
names instead of file names.
从help call命令:
Substitution of batch parameters (%n) has been enhanced. You can
now use the following optional syntax:
%~n1 - expands %1 to a file name only
%~x1 - expands %1 to a file extension only