Hello,
I want to verify the content of the text read from the input file, before I transfer it to an out file.
I did try to put its content into a variable, but it doesn't work.
Some body can help me please?
Thanks.
for /F "tokens=1* delims=]" %%j in ('type "%param%" ^| find /V /N ""') do (
Set subStr=%%k:~0,12%%
)
However the following works:
for /F "tokens=1* delims=]" %%j in ('type "%param%" ^| find /V /N ""') do (
echo.%%k>> "OutputFile"
)
Verifying the content of the read string from input file
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
substrings do not work on for variables (%%k). You have to assign a "normal" variable first and then do the substring.
Since you're inside a for loop, you'll have to use delayedexpansion like this:
*untested*
You could also do this without delayedexpansion:
Since you're inside a for loop, you'll have to use delayedexpansion like this:
*untested*
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /F "tokens=1* delims=]" %%j in ('type "%param%" ^| find /V /N ""') do (
set "tmpvar=%%~k"
set "subStr=!tmpvar:~0,12!"
)
You could also do this without delayedexpansion:
Code: Select all
@echo off
for /F "tokens=1* delims=]" %%j in ('type "%param%" ^| find /V /N ""') do (
set "tmpvar=%%~k"
call set "subStr=%%tmpvar:~0,12%%"
)