Solved

how do we create parameter file for batch script?

Posted on 2014-12-10
4
387 Views
Last Modified: 2014-12-10
i have FILE X with list of values for A,B,C as 1,2,3. i have FILE Y where i use these values A,B, and C wherever required in FILE B. it should get the value of A,B,C from FILE X and show as 1,2,3 respectively.

please let me know if i can be more clear !
0
Comment
Question by:naveen mullaguri
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 40490956
You can call another batch, or read one.

e.g.

filex.cmd

@echo off
set A=1
set B=2
set C=3

Open in new window



filey.cmd
@echo off
call filex.cmd
echo Now they are %a% %b% %c%

Open in new window


or you can read contents of a file, e.g.

filex.txt
A,1
B,2
C,3

Open in new window


@Echo off
for /f "tokens=1,2 delims=," %%a in ('type filex.txt') do set %%a=%%b
echo %a%, %b%, %c%

Open in new window


That should read filex.txt and for each line use the first bit before , as the variable name and the bit after the , as the value dynamically.

Is that what you are after?
0
 
LVL 82

Expert Comment

by:oBdA
ID: 40490970
If your "file x" is indeed has indeed the content as "1,2,3", you can import this into a batch file like this:
@echo off
setlocal
set ValueFile=x.txt
for /f "tokens=1-3 delims=," %%a in ('type "%ValueFile%"') do (
	set A=%%a
	set B=%%b
	set C=%%c
)
echo A: '%A%', A: '%B%', C: '%C%'

Open in new window

If not, please provide a concrete sample.
0
 

Author Closing Comment

by:naveen mullaguri
ID: 40491644
Thank you so much.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40491697
No problem, ask if not sure on anything.

Steve
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now