Copy files from multiple folders

Dell 2800
April 11, 2009 at 22:58:17
Specs: Windows 2003 Server, Xeon 2.6
Dear All,

I have a setup which requires me to remove 2 files from 20 folders every day and let them get regenerated each morning. After the month-end I need to merge them all together.

My files are in the following location:

\\server\survey\a\1.txt
\\server\survey\a\2.txt
\\server\survey\b\1.txt
\\server\survey\b\2.txt

etc.

I need 1.txt and 2.txt at O:\survey\%date%\

Is there an easy way to do this? And yes, 1.txt and 2.txt files should be merged while being copied there.

Thanks for any help, I am trying to do this with a batch but it would not take the wildcards.

Ben


See More: Copy files from multiple folders

Report •


#1
April 12, 2009 at 00:48:25
For starters, you won't have much luck with a dir named %date% as it will often contain illegal chars; / \ : to mention a few.

Beyond that, do you want to merge al the 1.txt and merge all the 2.txt separately or all 1s and 2s together?


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
April 12, 2009 at 00:57:07
Hi thanks for picking this up.

The %date% is set up to produce a DD-MM-YYYY string, no illegal characters there. I use this variable in many of my scripts.

All the 1.txt's should go to one file and the 2.txt's into another file, producing 2 files all together at the end.

Thanks a lot,

Ben


Report •

#3
April 12, 2009 at 01:56:57
:: merhe all 1.txt and 2.txt
:: not tested ; I don't have a network

@echo off & setLocal EnableDelayedExpansion

pushd \\server\survey

for /L %%a in (a b c d) do (
type %%a\1.txt >> O:\survey\%date%\1.txt
type %%a\2.txt >> O:\survey\%date%\2.txt
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions

#4
April 12, 2009 at 04:38:35
Hi,

Unfortunately this does not work, it ends up in a continuous loop, dont know why. I am going to write the script manually, there will be 40 lines but still doable.

Thanks a lot,

Ben


Report •


Ask Question