Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

can't set variable "id" to %%x

This is My Code

setlocal enabledelayedexpansion
for /F "delims=" %%x in (File.t0rrent) do (
set id = %%x
)
echo %id%
timeout /t 1000

the file "File.t0rrent"
was

**please dont edit this file**
*1405448673291003119829*
1234

it meant to be saying "1234"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

but it says "ECHO is off."

Please Help

>Solution :

  1. there should be no spaces between assign statements

wrong:

set id = %%x

correct:

set id=%%x

  1. if you use "setlocal enabledelayedexpansion", then you should use !variable! instead of %variable%

correct code is below:

echo off
setlocal enabledelayedexpansion
for /F "delims=" %%x in (File.t0rrent) do (
set id=%%x
)
echo !id!
timeout /t 1000
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading