Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

NT Batch files

  • 07-06-2001 10:39AM
    #1
    Registered Users, Registered Users 2 Posts: 4,660 ✭✭✭


    Quick question.
    How do i set a variable to a command.

    eg
    i want TEST to contain a listing of files in the current firectory.

    so %TEST% will be equal to index.html test.html blah.html

    follow ?
    any ideas ?
    Cheers,
    Gav


Comments

  • Closed Accounts Posts: 1,341 ✭✭✭Koopa


    well, if you can specify %test% to be a file on the hard disk (i dunno if you can), and do
    dir /b/l c:\ > %test%
    it might work, dunno much about NT batch file variables though so im not sure


  • Registered Users, Registered Users 2 Posts: 1,825 ✭✭✭Gambler


    Nope, you can't set it up like that.. What do you want to use the %temp% Variable for?, might be able to help you find another way round it..



  • Registered Users, Registered Users 2 Posts: 4,660 ✭✭✭Gavin


    Thanks for replies.
    I just ended up rewriting the thing.

    Works.. tis a bit klud*** though.

    ps a program called aset can be used to
    instantiate variables to command results.

    Gav


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    You can't do it that way.

    However what exactly do you want to do with the list of files?

    You could do something like this...

    for %x in (*.*) do echo %x exists!

    (change %x to %%x if putting into a batch file).
    <font face="Verdana, Arial" size="2">Originally posted by Verb:
    Quick question.
    How do i set a variable to a command.

    eg
    i want TEST to contain a listing of files in the current firectory.

    so %TEST% will be equal to index.html test.html blah.html

    follow ?
    any ideas ?
    Cheers,
    Gav
    </font>



Advertisement