You can get the value in a variable without creating/read a file and in a line..
@echo off
>"c:\demo.txt" (
echo # Title to be displayed
echo # Purpose to count the directories in a folder
for /f %%i in ('dir/b/ad "C:\Users\rjmac\Documents\Code"^|find/c /v ""')do set "count=%%~i"
echo # FolderCount Value = %count%
)