批次循环排除包含文件名 [英] Batch For loop exclude file name that contains
本文介绍了批次循环排除包含文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个简单的批处理文件,将遍历所有* Test.htm的文件,并复制它们。某些文件将包含我不想要复制的字符串。
FOR / RC:\\%%克(* Test.htm的)DO(
回声%%摹
)
我想在伪code什么:
关闭@echo
FOR / RC:\\%%克(* Test.htm的)DO(
如果%%摹包含排除无可奈何
其他
复制...
)
解决方案
对于文件名:
关闭@echoFOR / RC:\\%%克(* Test.htm的)DO(
(回声%% G| FIND / I排除1> NUL)|| (
复制%% G......
)
)
对于文件的内容:
关闭@echoFOR / RC:\\%%克(* Test.htm的)DO(
(类型%% G| FIND / I排除1> NUL)|| (
复制%% G......
)
)
I have a simple batch file that will loop through all *Test.htm files and copy them. Some of the files will contain a string that I don't want to copy.
FOR /R "C:\" %%g IN (*Test.htm) DO (
echo %%g
)
What I want in pseudo code:
@echo off
FOR /R "C:\" %%g IN (*Test.htm) DO (
if %%g contains "Exclude" do nothing
else
copy...
)
解决方案
For filename:
@echo off
FOR /R "C:\" %%g IN (*Test.htm) DO (
(Echo "%%g" | FIND /I "Exclude" 1>NUL) || (
Copy "%%g"...
)
)
For File content:
@echo off
FOR /R "C:\" %%g IN (*Test.htm) DO (
(Type "%%g" | FIND /I "Exclude" 1>NUL) || (
Copy "%%g"...
)
)
这篇关于批次循环排除包含文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文