Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dos Batch file for copying a file

Status
Not open for further replies.

Ultdrake

Programmer
Joined
Jul 15, 2002
Messages
19
Location
CA
My directory tree is like this :

Project
-- Boat
----- daya
-------- linea
...
-------- linex
...
----- dayx
-------- linea
...
-------- linex

Exemple : I want to copy from a variable path a file name allo.txt to each lineX directory, each time I don't know how many days and line I have...

For now my batch file are like this (and does'nt work :-( )

echo begin
:Loop
IF "%1"=="" GOTO Continue
copy allo.txt "%1"
echo fin loop
SHIFT
GOTO Loop
:Continue

the parameter is the path of each line, I want change this method to automatize like i say before... thanks a lot...

Fred Cloutier
 
Give this a try...

1. Pickup Sweep, which replicates a command in all lower subdirectories, Charles Petzold, ca. 1986. There is one available at the Sophos site. There are probably many copies of his SWEEP around.

2. Each time, see if there is a directory named linex and if So copy the file.

3. You need to know that
if exist pathA\nul
tests for the existence of folder pathA
BAT
so
Code:
If Exist linex\nul
will tell us if there is a lower linex folder.

4. the file to be copied has to be in a certain place, like C:\allo.txt as Sweep will be changing the CWD as it goes. Cannot be relatively named.

5. change dir to the top of the area, \Project and do


Code:
Sweep doit

which will replicate DOIT.BAT in all lower folders.

doit.bat
Code:
  if exist linex\nul copy c:\allo.txt linex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top