Solved

how do we create parameter file for batch script?

Posted on 2014-12-10
4
390 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 83

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

773 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