Solved

how do we create parameter file for batch script?

Posted on 2014-12-10
4
401 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 84

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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