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

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

Report •

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

@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

Simple solutions are often the best

Report •

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

thanks this worked just fine !

Report •
Related Solutions

Ask Question