@echo off
setlocal enabledelayedexpansion
Set sz=
for /f "tokens=5 delims= " %%a in
('type mytext.txt') Do (Set sz=!sz!+%%a)
echo !sz!
if mytext.txt is empty , do statement does not get executed and the statement
,echo !sz!, results in ,!sz! itself. How can i check the sz to see if mytext.txt is empty or not?.
null string
Moderator: DosItHelp
Re: null string
Code: Select all
for %%a in ("mytext.txt") do set sz=%%~za
The same thing works for batch file and function call arguments. Assume %1 contains your file name:
Code: Select all
set sz=%~z1
Try HELP FOR and HELP CALL for a full list of expansion modifiers.
Dave Benham