Computing.Net > Forums > Programming > Batch File: Get Words

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File: Get Words

Reply to Message Icon

Name: CWoodward
Date: February 8, 2006 at 16:57:32 Pacific
OS: Windows XP
CPU/Ram: Intel Celleron
Comment:

Hello! I have a text file that contains a single line of words. I am trying to make a batch file that will get the contents of that file and set it as a variable without knowing what words those are (I.E. Without using the FIND command.) Could someone please help me?

Thanks,
Cale



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: February 8, 2006 at 18:02:44 Pacific
Reply:

Hi Cale,

Is the needed word always in the same place?

That is, always the 3rd word; 5th word, etc?


If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: CWoodward
Date: February 8, 2006 at 18:06:26 Pacific
Reply:

I think would need the entire line of words


0

Response Number 3
Name: Mechanix2Go
Date: February 8, 2006 at 18:11:02 Pacific
Reply:

huh?


If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: CWoodward
Date: February 8, 2006 at 18:14:25 Pacific
Reply:

Sorry, I just checked the file, I only need the first word


0

Response Number 5
Name: Mechanix2Go
Date: February 8, 2006 at 18:21:27 Pacific
Reply:

If your file is cakked:

fox

Try this:

::== firstWRD.bat
@echo off
for /f "tokens=1" %%W in (fox) do set myVAR=%%W
echo %myVAR%
:: DONE


If at first you don't succeed, you're about average.

M2


0

Related Posts

See More



Response Number 6
Name: CWoodward
Date: February 8, 2006 at 18:34:53 Pacific
Reply:

Works great. Thanks


0

Response Number 7
Name: CWoodward
Date: February 8, 2006 at 18:39:17 Pacific
Reply:

Is there any way of setting an entire line of words to a variable?


0

Response Number 8
Name: Mechanix2Go
Date: February 8, 2006 at 19:33:46 Pacific
Reply:

Change tokens=1

to:

tokens=*


If at first you don't succeed, you're about average.

M2


0

Response Number 9
Name: CWoodward
Date: February 8, 2006 at 20:34:45 Pacific
Reply:

Thanks M2. What would we ever do without you?


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File: Get Words

Batch file exits after GET command www.computing.net/answers/programming/batch-file-exits-after-get-command/15735.html

Get a Folder size in a batch file www.computing.net/answers/programming/get-a-folder-size-in-a-batch-file/9587.html

windows xp batch file, edit ....... www.computing.net/answers/programming/windows-xp-batch-file-edit-/9278.html