1

I am trying to create a windows batch to loop through multiple folders and copy *.txt from each to a single target folder. Here is where i have started:

set inbox=C:\Test\inbox
for %%i in (C:\Test\Archive\ C:\Test\temp\) do (xcopy %%i\*.txt %inbox%\)
Cody Gray
  • 230,875
  • 49
  • 477
  • 553
Georgep2000
  • 39
  • 2
  • 7

2 Answers2

2

Try like this code :

@echo off
set source="C:\Test\Archive" "C:\Test\temp"
set Target=C:\Test\inbox
for %%i in (%source%) do (xcopy "%%~i\*.txt" "%Target%" /Y /I /D)
pause
Hackoo
  • 16,942
  • 3
  • 35
  • 62
0

Check this solution:

How to do something to each file in a directory with a batch script

Basically, looks like the first parentheses part should be

('dir /b C:\Test\Archive\ C:\Test\temp')

I'm not sure how that works with two directories - I think it should work but may require doing two runs and merging results.

Community
  • 1
  • 1