本文介绍了如果属性匹配,则复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因为我是刚开始批量生产,请多多包涵.
please bear with me since I'am new to batch.
仅在两个属性匹配时,我才尝试将文件从一个位置复制到另一位置.
I'am trying to copy files from one location to another only if two attributes are matching.
我尝试并进行了修改,但没有成功:
I tried around and modify but didn't succeed with:
set dSource=\\server5\Datapool
set dTarget=C:\Users\folder1
set fType=*.xml
for /F "tokens=1,2 delims=:<>" %%a, in ('findstr "Name=\"Marc\"" *.xml|findstr "testcar=\"BENZ231\"" *.xml') do (
copy /V "%%a" "%dTarget%\" 2>nul
)
所以我的目标是仅在Marc + BENZ231匹配时才复制XML文件.
So my goal is to copy XML files only if Marc+BENZ231 match.
XML文件的确如下所示:
XML files do look like this:
<testInfo testDuration="57" holidayCount="0" completedtask="12" Name="Marc" testVersion="13" testcar="BENZ231"
<result testStepName="locating" sequenceNrResult="1" testStepResult="OK">
etc.
</testInfo>
</testresult>
推荐答案
-----------------test.bat--------------
@echo off&pushd \\server5\Datapool
for /f %%a in ('dir /b ^| find ".xml"') do for /f %%A in ('type %%a ^| find /I "Marc" ^| find /I "BENZ231"') do copy %%a C:\Users\folder1
-----------------test.bat--------------
立即了解.这个对我来说还不错!
Got it now. This one just worked fine for me!
这篇关于如果属性匹配,则复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!