DOS dir /B: want to store evaluated output

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Vertebraille
Posts: 2
Joined: 09 Apr 2008 19:59

DOS dir /B: want to store evaluated output

#1 Post by Vertebraille » 09 Apr 2008 20:07

Hi,
I've got to write a batch file at work which renames a file (slx_callhistory*.txt) to slx_callhistory.txt, calls an external app, then renames slx_callhistory back to what it was originally

the problem i'm having is, i'm doing a

dir slx_callhistory*.txt /B, and trying to set this output in a variable,
but I don't want the variable to contain the dir call, i want it to contain the output

is there any way of doing this, or can somebody suggest a better way to go about the problem?
Thanks

Vertebraille
Posts: 2
Joined: 09 Apr 2008 19:59

#2 Post by Vertebraille » 09 Apr 2008 22:31

solved!
used FOR /F %%a IN ('dir slx_opportunity*.txt /B') DO (SET thefilename=%%a).

DosItHelp
Expert
Posts: 239
Joined: 18 Feb 2006 19:54

#3 Post by DosItHelp » 29 Apr 2008 01:12

Or simply:
FOR %%a IN (slx_opportunity*.txt) DO SET thefilename=%%a
:wink:

Post Reply