Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,453 of 42,547    |
|    griffin188@gmail.com to All    |
|    Re: How to I place the contents of a fil    |
|    26 May 16 13:17:16    |
      On Sunday, May 1, 2016 at 10:10:01 PM UTC-5, T wrote:       > On 05/01/2016 04:09 PM, T wrote:       > > Hi All,       > >       > > How to I place the contents of a file into a variable?       > >       > > I am looking for something like the following bash       > > variable assignment but in "batch"       > >       > > #!/bin/bash       > > Count=$(cat CountFile.txt)       > >       > > Many thanks,       > > -T       >       >       > I found this in my notes. Is there a less complicated method?       >       > echo sri_test.txt>> out.txt       > For /f "tokens=* delims= " %%a in (out.txt) do set myvar=%%a       > echo %myvar%              I have only been able to pull data in from a file with the usebackq option              1. Depending on your data you may not even need tokens. I'd start with this:       For /f "usebackq delims=" %%a in (out.txt) do (set myvar=%%a)              2. Then add tokens if necessary (Step 1 should output the same as step 2):       For /f "usebackq tokens=* delims=" %%a in (out.txt) (do set myvar=%%a)              3. Then add my deliminators last:       For /f "usebackq tokens=* delims= " %%a in (out.txt) do (       set myvar=%%a       @echo !myvar!       )              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca