Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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!

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!

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!

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

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!

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

![]() |
![]() |
![]() |

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