Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

how to read entire file into environment variable?

Jul
532
10
I want to read all the lines of a text file into an environment variable.

I had tried using %@EXECSTR[type file] but that only got the first line

Anyone already done this and have an example to share?
 
I have a file called games.txt, thus;
Code:
Gaming Laptop

NVIDIA Graphics Processor
- 6GB Minimum

Windows 10 Pro

Video
- 4K Video
- 17 inch minimum

16GB RAM Minimum

Intel CPU
- At least 6 cores
- Example: Intel Core i7-10750H

If the version of TCC that you are using has the pshell command;

Code:
pshell /s "$env:BigFile = Get-Content e:\utils\games.txt -Raw"

echo %BigFile
Gaming Laptop

NVIDIA Graphics Processor
- 6GB Minimum

Windows 10 Pro

Video
- 4K Video
- 17 inch minimum

16GB RAM Minimum

Intel CPU
- At least 6 cores
- Example: Intel Core i7-10750H

Joe
 
I tried that out, but alas, it consistently crashes my TCC (v29.00.17 x64) window entirely.
 
BTW, the answer for me ended up being this, though for me I separated each line with " / " because I actually wanted it to squish all onto one line for my situation:

Code:
            DO line IN @%TXT_FILE (
                set FILE=%FILE% / %line%
            )
 
Back
Top