Computing.Net > Forums > Windows 2000 > Use file contents to SET variables

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.

Use file contents to SET variables

Reply to Message Icon

Name: MOXErik
Date: October 4, 2005 at 12:42:23 Pacific
OS: Win 2K
CPU/Ram: P4 EE 3.2 / 3 GB
Comment:

This should be simple enough: It would be useful to use the SET command to assign a variable to the text contained within a file. I just don't know how to do it. Do you?

Imagine one has a file named "name" within the directory. The text contained within the file is, say, "file123.op3" (no quotes, of course). In a batch file, I would like to be able to use the SET commant to assign "file123.op3" - or whatever happens to be contained within "name" to another variable. Let's call the variable "op3file". When all's said and done, I would like to examine %op3file% and find that it contains "file123.op3".

Is this not as simple as I assume? I find no references to the operation. How embarrassing. :)

Thank you for your thoughts!



Sponsored Link
Ads by Google

Response Number 1
Name: MOXErik
Date: October 4, 2005 at 13:07:55 Pacific
Reply:

By trial-and-error, I have discovered the answer to my own question. Now I don't know which is the more embarrassing - my question or my approach to the answer: type this - nope, type that - nope, change order - dang it!, search the web - no dice, type something else - aha!

Anyway, For the benefit of others trying to get DOS to do the same, let me post what worked:

In the example I gave, the correct syntax would be

"set /p op3file<name" (no quotes, of course)

Kind of esoteric, huh?

Thanks for your thoughts!


0

Response Number 2
Name: MOXErik
Date: October 4, 2005 at 13:19:28 Pacific
Reply:

Gotcha, Dr. Erdmann.

:)

FYI, I have verified the necessity of the /p switch. It doesn't work without it on my machine.

Thanks for your thoughts!


0

Response Number 3
Name: Mechanix2Go
Date: October 4, 2005 at 22:12:58 Pacific
Reply:

Hi Erik,

Good work.

The answer is hiding:

set /?

BTW, it does NOT work in DOS. Only in CMD.exe


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

M2


0

Response Number 4
Name: MOXErik
Date: October 5, 2005 at 13:42:58 Pacific
Reply:

Thank you, M2.

Hmmm... So does "DOS" even still exist? If not, does everyone call it "CMD.exe" now? That's kind of cumbersome.

I'm probably like other "about average" individuals who don't often work within the command-line environment, who forget what they learn the day after they quit using it, and who really don't get the nuances that distinguish "DOS" from "CMD.exe". To such, it's the same little black window and frumpy fonts, no mounse, more-or-less the same little, cryptic commands - you know: "dir" "cd" "format" and so on.

I'm just glad, when anything works at all.

:)

Thanks for your thoughts!


0

Response Number 5
Name: Mechanix2Go
Date: October 5, 2005 at 17:22:50 Pacific
Reply:

Hi Erik,

I like the way you put it.

To me, it's all about the same: command line.

BTW, w2k CMD is somewhat "mouseable". As long as your CMD in not full screen.

Try highlighting something here; go to a CMD prompt and right click.


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

M2


0

Related Posts

See More



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 Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Use file contents to SET variables

Using a GPO to set profile path in W2K.. www.computing.net/answers/windows-2000/using-a-gpo-to-set-profile-path-in-w2k/12505.html

File folder Content-type setting www.computing.net/answers/windows-2000/file-folder-contenttype-setting/19382.html

set variable value to the output of commands www.computing.net/answers/windows-2000/set-variable-value-to-the-output-of-commands/65750.html