@echo off
setlocal enableextensions enabledelayedexpansion
set CHECKSUM_TOOL=fciv.exe
set DESTINATION_DIR=C:\Documents and Settings\Users\Desktop\testfolder
set CHECKSUM=12345
set APP_NAME=price
set VERIFY_FILE=testfile.txt
for /f "tokens=1" %%m in ('call "%CHECKSUM_TOOL%" -md5
"%DESTINATION_DIR%\!VERIFY_FILE!"') do (
for /f "tokens=1 delims=/ " %%n in ("%%m") do (
set CURRENT_CHECKSUM="%%n"
if not !CURRENT_CHECKSUM!==!CHECKSUM! (
echo %DATE% %TIME% [ERROR] %~nx0: Checksum of existing file !CURRENT_CHECKSUM! does not match manifest !CHECKSUM! for %APP_NAME%
REM exit 1
)
)
)
So i have the above batch script. The problem is when i print out the value of CURRENT_CHECKSUM the file directory is truncated and instead of echoing
C:\Documents and Settings\Users\Desktop\testfolder\testfile.txt
I instead get
c:\documents
output to the fciv call returns
bd4e8c3e9b3a880365619e48a779e8e0 c:\documents and settings\Users\desktop\testfolder\testfile.txt
delims=in your first loop? Try also: quoting the variables in set likeset "var=value", quoting both values inifstatement and a space after==likeif not "!CURRENT_CHECKSUM!" == "!CHECKSUM!", e.t.c.!VERIFY_FILE!is not needed, also. Can you please explain what the output of the command parsed in thefor /Floop will be? I am not familiar withfciv.exefciv.exein your question by editing it! You rissue is not related to escaping, it is the usage offor /F:for /F "tokens=1*" ...would return two tokens, separated by the first (sequence of) whitespace(s), so the second one may even contain whitespaces on its own...