Solved Copy Files If Attributes Match

April 19, 2017 at 04:43:16
Specs: Windows 7
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
)

XML files do look like this and the strings are on the same line:

<testInfo testsequence="1357" DayOffCounter="0" completedtask="12" Name="Marc" testCar="BENZ231">
</testInfo>

My goal is to copy XML files only if Marc+BENZ231 match to another Folder.

Many thanks in advance !


See More: Copy Files If Attributes Match

Reply ↓  Report •


#1
April 19, 2017 at 06:16:17
✔ Best Answer
this should do it:

-----------------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--------------

Simple solutions are often the best


Reply ↓  Report •

#2
April 19, 2017 at 19:21:24
Hey hidde663 again :)

thanks this worked just fine !


Reply ↓  Report •
Related Solutions


Ask Question