.Bat File calling with other .bat file with paramater isue
Posted: 21 Aug 2019 00:21
Hi Friends,
I have Script below in one .bat file and am calling other .bat file which contained the function
but it is not working.
-------Bat1.bat
@echo off
setlocal enableExtensions disableDelayedExpansion
set file=D:\Rajnish_GTT\R1Test.txt
for /f "tokens=1 delims=, " %%a in (%file% ) do (
setlocal enabledelayedexpansion
SET "string1=%%a" & CALL D:\Rajnish_GTT\islength.bat result1 !string1! -----> Calling other .bat file with parameter.
if "!result1!" GTR "6" (
echo(field "%%~a" Not a 6 Digit Long)
)
)
---------------Bat2.bat
@echo off
setlocal enableExtensions disableDelayedExpansion
(
SET S="S=!%~2!#"
SET "LEN=0"
FOR %%P IN (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) DO (
IF "!S:~%%P,1!" NEQ "" (
SET "S=!S:~%%P!"
)
)
)
(
ENDLOCAL
SET "%~1=%LEN%"
EXIT /B
)
Example data as below.
id
001 --- return 4 digit.
A002 --- return 6 digit.
Second .bat file checking the length of fields.
Kindly help.
I have Script below in one .bat file and am calling other .bat file which contained the function
but it is not working.
-------Bat1.bat
@echo off
setlocal enableExtensions disableDelayedExpansion
set file=D:\Rajnish_GTT\R1Test.txt
for /f "tokens=1 delims=, " %%a in (%file% ) do (
setlocal enabledelayedexpansion
SET "string1=%%a" & CALL D:\Rajnish_GTT\islength.bat result1 !string1! -----> Calling other .bat file with parameter.
if "!result1!" GTR "6" (
echo(field "%%~a" Not a 6 Digit Long)
)
)
---------------Bat2.bat
@echo off
setlocal enableExtensions disableDelayedExpansion
(
SET S="S=!%~2!#"
SET "LEN=0"
FOR %%P IN (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) DO (
IF "!S:~%%P,1!" NEQ "" (
SET "S=!S:~%%P!"
)
)
)
(
ENDLOCAL
SET "%~1=%LEN%"
EXIT /B
)
Example data as below.
id
001 --- return 4 digit.
A002 --- return 6 digit.
Second .bat file checking the length of fields.
Kindly help.