When writing for loops in cmd scripts the for variables (ex: %i) needs to be escaped with a extra % so it becomes:
for /f "tokens=1,2,3,4 delims=_." %%i in (file.txt) do ren "%%i_%%j_%%k.%%l" "%date:~10%%date:~4,2%%date:~7,2%_%time:~0,2%h%time:~3,2%m%time:~6,2%s_%%k.%%l"
To read more how for works type for /?
in cmd.
The interesting part:
To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I.