[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

script help

Posted on 2005-05-10
9
Medium Priority
?
136 Views
Last Modified: 2010-04-14
hello,

I have data in a .txt file like this
John.PA
Ron.MA
Mor.NV

I am writing the code to get the data in two variables
like
one variable will have data before the . and the other after.
like this
one variable have John and the other will have PA

FOR /F " tokens=1,2 delims=. " %%i in (C:\names.txt) do echo  "%%i" "%%j"

set Name=JOHn
Set city=PA

loop
set Name=Ron
Set City=MA

Thanks In advance


0
Comment
Question by:schinni
  • 4
  • 3
7 Comments
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13974335
What's the question?  Your comments are confusing as to what you are looking for...
0
 

Author Comment

by:schinni
ID: 13974382
i am trying to read from a text fike and set that data into two variables
..

set Name=JOHn
echo %name%

Set city=PA
echo %city%


Hope this is not confusing ..pls let me know

thx
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 13974594
Ok... Are you trying to loop through the data?  Because in your example, only the last entry will be set to those variables.  Say you have those variables set, what are you planning to do with that info?

This will do what your asking, but it doesn't make much sense to me.  Can you elaborate on what EXACTLY you are trying to accomplish.  Data to variables is obvious enough, but what then?

FOR /F "tokens=1,2 delims=." %%a in (C:\names.txt) do (
set Name=%%a
set city=%%b
)
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 

Author Comment

by:schinni
ID: 13977640
I am trying to do something like this

I am trying to read the data from that text file and
set the variables with that data
and there is my logic which uses those variables


FOR /F "tokens=1,2 delims=." %%a in (C:\names.txt) do  call :processes "%%a"

:processes

set Name=%%a
Echo %Name%
set city=%%b
Echo %city%


here i have my code where i will pass those variables Name and City
and it loop thru untill it reads all the data in the texr file)


Hope I am not confusing you too much.
0
 
LVL 97

Accepted Solution

by:
Lee W, MVP earned 400 total points
ID: 13978999
That's a bit more clear - use this


FOR /F "tokens=1,2 delims=." %%a in (C:\names.txt) do  call :processes %%a %%b

:processes

set Name=%1
Echo %Name%
set city=%2
Echo %city%


Note the changes in the Processes section - %%a is now %1 and %%b is now %2.  Also note the Call has both variables and no quotes.
0
 

Author Comment

by:schinni
ID: 13982816
thanks very much..I am going  to try this  and let you know..
0
 

Author Comment

by:schinni
ID: 13992537
Thanks Very Much ..That worked
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 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