[Total: 0    Average: 0/5]

Often I need to load the content of a file into a Windows Command Prompt variable. This is useful when writing batch scripts where the return value from one program is used as input for another program. At other times I need to process a json file to load just a value into a variable.

Note: There is a limit to the size of variables. I think the limit is 1024 bytes.

Let’s start with a sample test file “testfile”:

And another sample test file “testfile.json”:

Load the first line from testfile into a variable:

This outputs:

Load the last line from testfile into a variable:

This outputs:

Load all lines from testfile.json into a variable:

This outputs:

Load just a value from a json file:

This outputs:

Load just a value from a json file without the quotes:

This outputs: