Computing.Net > Forums > Programming > Copying Batch to another batch

Copying Batch to another batch

Reply to Message Icon

Original Message
Name: Darkfire
Date: September 28, 2005 at 10:05:29 Pacific
Subject: Copying Batch to another batch
OS: Windows XP
CPU/Ram: Pentium 4, dunno my ram
Comment:

Hi! Im just wondering how would you scan for all .bat files in a directory, and then add a different bat file's commands to those batch files. Making sense? i wan the commands to be executed when the batch file i have copied to runs. Thx for your time and patience


Report Offensive Message For Removal


Response Number 1
Name: dtech10
Date: September 29, 2005 at 17:55:46 Pacific
Reply: (edit)

Hi
Do you mean something like this.
@echo off
rem x.bat=Batch File with commands in it.
rem test.bat=This Batch File
rem I'm assuming they all in the same folder
dir *.bat /b | find /v "x.bat" > Files.tmp
for /f %%a in (Files.tmp) do (
if not "%%a"=="test.bat" (
for /f "tokens=*" %%b in (x.bat) do echo %%b >> %%a
)
)
del Files.tmp


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Copying Batch to another batch

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge