Q:

change the time output of the time variable in windows command line to use in batch file

Goal: Backup files from subdirectories with a specific extension to another directory using a batch file. 
forfiles /P C:\Users\user\Desktop\testdest\ -D 3 /C "cmd /c IF @isdir == TRUE rd /S /Q @path" 
mkdir C:\Users\user\Desktop\testdest\%date%
FOR /R C:\Users\user\Desktop\testsrc\ %%A in (*.txt) do (
echo %%A
copy "%%A" "C:\Users\user\Desktop\testdest\%DATE%\%time:~0,2%_%time:~3,2%_%time:~6,2%_%time:~9,2%_%%~nxA
)

I tried multiple ways finding a way to make the file names unique.  
Unfortunately there are files in the subdirectories that have the same name as files in other subdirectories, so to make them unique in the target directory, they need a pre- or postfix that makes them unique. 
Tried a counter variable, but could not figure out how to increment it. 
I ended up trying to use the time variable, but it seems to stay the same in the whole batch file run. 
Output is like this:
copy "C:\Users\user\Desktop\testsrc\sub\subsub\311.txt" "C:\Users\user\Desktop\testdest\01.02.2018\ 9_24_31_52_311.txt

copy "C:\Users\user\Desktop\testsrc\sub\subsub\312.txt" "C:\Users\user\Desktop\testdest\01.02.2018\ 9_24_31_52_312.txt

the time output stays the same, what is a problem, when there are multiple files with the same name. 
So why is the time output not changing the millisecond? 

A:

Try with delayed expansion:
setlocal enableDelayedExpansion
forfiles /P C:\Users\user\Desktop\testdest\ -D 3 /C "cmd /c IF @isdir == TRUE rd /S /Q @path" 
mkdir C:\Users\user\Desktop\testdest\%date%
FOR /R C:\Users\user\Desktop\testsrc\ %%A in (*.txt) do (
  echo %%A
  copy "%%A" "C:\Users\user\Desktop\testdest\%DATE%\!time:~0,2!_!time:~3,2!_!time:~6,2!_!time:~9,2!_%%~nxA
)

Mind that the %time% could differ on different machines as it relies on local settings.