Apologies for the simplicity of this, but Batch is not my native tongue
Im trying to clean up a script to use variables as paths rather than defining them inline. But everytime i put a variable name into the for loop it fails.
So the following snip works
Code: Select all
setlocal EnableDelayedExpansion
set tempfile="c:\windows\temp\diskpart_create_tmp.txt"
set listfile="C:\windows\temp\diskpark_listdisks_tmp.txt"
set otherfile="C:\windows\temp\diskpart_listdisks_output.txt"
echo off
ECHO rescan>!listfile!
ECHO list disk >>!listfile!
diskpart /s !listfile! > !otherfile!
for /F "skip=12 tokens=2-6" %%a in (C:\windows\temp\diskpart_listdisks_output.txt) do (
echo %%a %%b %%c %%d %%e
but this does not
Code: Select all
setlocal EnableDelayedExpansion
set tempfile="c:\windows\temp\diskpart_create_tmp.txt"
set listfile="C:\windows\temp\diskpark_listdisks_tmp.txt"
set otherfile="C:\windows\temp\diskpart_listdisks_output.txt"
echo off
ECHO rescan>!listfile!
ECHO list disk >>!listfile!
diskpart /s !listfile! > !otherfile!
for /F "skip=12 tokens=2-6" %%a in (!otherfile!) do (
echo %%a %%b %%c %%d %%e
Anyone have any idea what im doing wrong?
Thanks in Advance
R