Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file Can';t使用FOR/R复制具有多个扩展名的文件_Batch File - Fatal编程技术网

Batch file Can';t使用FOR/R复制具有多个扩展名的文件

Batch file Can';t使用FOR/R复制具有多个扩展名的文件,batch-file,Batch File,我无法在同一行中使用两个扩展来处理/r的整个 我有一个很大的文件夹,里面有.log、.html和.js,我试图基本上使用for/r的东西来复制.log和.js。我曾经成功过,但最近失去了成功 我尝试了所有这些方法来列出多个扩展 (*.log;*.js) (*.log,*.js) (*.log),(*.js) (*.log);(*.js) 但我仍然不确定以下内容中的正确语法是什么: for /r "d:\temp" %c in (*.log; *.js) do copy "%c" "d:\tem

我无法在同一行中使用两个扩展来处理/r的整个

我有一个很大的文件夹,里面有
.log
.html
.js
,我试图基本上使用
for/r
的东西来
复制
.log
.js
。我曾经成功过,但最近失去了成功

我尝试了所有这些方法来列出多个扩展

(*.log;*.js)
(*.log,*.js)
(*.log),(*.js)
(*.log);(*.js)
但我仍然不确定以下内容中的正确语法是什么:

for /r "d:\temp" %c in (*.log; *.js) do copy "%c" "d:\temp2"

这两种文件类型都应该复制到目标文件夹,但它们不复制到目标文件夹。

我用逗号处理了它:(请注意,我没有太多的.js文件要处理,因此我选择了.bin和.txt)


是什么让你决定使用分号,
(*.log;*.js)
,而不是说
(*.log,*.js)
(*.log*.js)
,双引号逗号或空格,
(*.log),“*.js”)
(“*.log”“*.js”)
,因为你的问题没有被标记,所以用
%c
而不是
%c
,谢谢。关于
%c
我只是不知道它是如何正常工作的。
对于(*.bin,*.txt)do dir/b%1中的/r%1
我看不正确,您是否确实打开了命令提示符窗口并输入了
for/?
以了解该命令的工作方式?是的,我确实这样做了,我实际上输入了命令,您可以看到输出。这是for/的一部分?这描述了/r:FOR/r[[drive:]path]%(set)DO命令[command parameters]中的变量遍历根在[drive:]path的目录树,在树的每个目录中执行FOR语句。如果/R之后未指定目录规范,则假定当前目录。如果set只是一个单句点(.)字符,那么它只会枚举目录树;请不要使用
1
,(或任何单个数字)作为
%变量
,它肯定会产生问题或误解。
C:\Windows\System32>for /r %1 in (*.bin,*.txt)  do dir /b %1
...
C:\Windows\System32>dir /b C:\Windows\System32\DriverStore\FileRepository

\netathr10x.inf_amd64_9ef98e989e52e32c\
eeprom_qca9377_1p1_NFA435_olpc_LE_2.bin
eeprom_qca9377_1p1_NFA435_olpc_LE_2.bin

C:\Windows\System32>dir /b C:\Windows\System32\DriverStore\FileRepository\netathr10x.inf_amd64_9ef98e989e52e32c\
qca61x4_1_1_2.bin
qca61x4_1_1_2.bin

C:\Windows\System32>dir /b C:\Windows\System32\DriverStore\FileRepository\netathr10x.inf_amd64_9ef98e989e52e32c\
qca61x4_2_2.bin
qca61x4_2_2.bin

C:\Windows\System32>dir /b C:\Windows\System32\DriverStore\FileRepository\netathr10x.inf_amd64_9ef98e989e52e32c\
qca9377_2_0.bin
qca9377_2_0.bin

C:\Windows\System32>dir /b C:\Windows\System32\DriverStore\FileRepository\netr28ux.inf_amd64_d5996f2a9d9aa9e3\FW
_7662.bin
FW_7662.bin

C:\Windows\System32>dir /b C:\Windows\System32\DriverStore\FileRepository\netr28ux.inf_amd64_d5996f2a9d9aa9e3\Pa
tch_7662.bin
Patch_7662.bin

C:\Windows\System32>dir /b C:\Windows\System32\Intel\Echo\m\cohort_echo.bin
cohort_echo.bin

C:\Windows\System32>dir /b C:\Windows\System32\Intel\HwKws\ReleaseNotes.txt
ReleaseNotes.txt

C:\Windows\System32>dir /b C:\Windows\System32\Intel\sid\ubm.bin
ubm.bin

C:\Windows\System32>dir /b C:\Windows\System32\MailContactsCalendarSync\LiveDomainList.txt
LiveDomainList.txt

C:\Windows\System32>dir /b C:\Windows\System32\restore\MachineGuid.txt
File Not Found

C:\Windows\System32>dir /b C:\Windows\System32\SecureBootUpdates\dbupdate.bin
dbupdate.bin

C:\Windows\System32>dir /b C:\Windows\System32\SecureBootUpdates\dbxupdate.bin
dbxupdate.bin

C:\Windows\System32>dir /b C:\Windows\System32\spool\drivers\x64\3\LMUD1N40.TXT
LMUD1N40.TXT

C:\Windows\System32>dir /b C:\Windows\System32\spool\drivers\x64\3\LMUD1P40.TXT
LMUD1P40.TXT

C:\Windows\System32>dir /b C:\Windows\System32\WindowsPowerShell\v1.0\en-US\default.help.txt
default.help.txt