在XML文件中搜索单词

时间:2021-10-02 20:08:02

I have almost 2000 files in folder where the count increases daily,and all the files are in .xml format.The primary requirement is to copy the files from one folder to other ,but checking if files contains "ABC" string.Also the files date should be day-1 till today's date.

我在文件夹中有近2000个文件,其中每天都有计数增加,所有文件都是.xml格式。主要要求是将文件从一个文件夹复制到另一个文件夹,但检查文件是否包含“ABC”字符串。还有文件日期应该是第1天到今天的日期。

I had tried using the below code

我曾尝试使用以下代码

@ECHO OFF
SETLOCAL
SET "sourcedir=C:\Users\Raul\Desktop\Test"
SET "destdir=C:\Users\Raul\Desktop\Output"
FOR /f "delims=" %%a IN ('findstr /m /L "ABC" "%sourcedir%\*.xml"') DO (
 echo(COPY "%%a" "%destdir%\%%~nxa"
)

GOTO :EOF

Can you help me to modify it? Help would be appreciated.

你能帮我修改一下吗?帮助将不胜感激。

1 个解决方案

#1


1  

It's working for a .xml file containing <payload type="ABC" version="0.1"> too. Do replace next line

它适用于包含 的.xml文件。请替换下一行

 echo(COPY "%%a" "%destdir%\%%~nxa"

to

 MOVE "%%a" "%destdir%\%%~nxa"

#1


1  

It's working for a .xml file containing <payload type="ABC" version="0.1"> too. Do replace next line

它适用于包含 的.xml文件。请替换下一行

 echo(COPY "%%a" "%destdir%\%%~nxa"

to

 MOVE "%%a" "%destdir%\%%~nxa"