Solved

how do we create parameter file for batch script?

Posted on 2014-12-10
4
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 85

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Configuring Remote Assistance for use with SCCM
Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…
Suggested Courses

617 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