@echo off
title DOS-Based Clock
set "color=0a"
:clock
cls
color %color%
echo the current time is: %time%
ping -n 2 127.0.0.1 > nul
goto %color%
:0a
set "color=7a"
goto clock
:7a
set "color=0a"
goto clock
Use a variable to store the color and use it both to change the color and to jump to the same label as the color, then change the value of the color and repeat the process