1

How to transform in one cmd line current date & time into file name without spaces?

I know how to do it in two lines:

set file_name=file_%date%-%time:~0,2%%time:~3,2%%time:~6,2%
rem echo %file_name% return "file_2015-08-01- 85012" and it's not ok 

(contain space)

set file_name=%file_name: =0%
echo echo %file_name% return "file_2015-08-01-085012" and it's ok

(no spaces)

but I can't run program in *.bat file - I have to run "original" *.exe which require all parameters in one line.

npocmaka
  • 55,367
  • 18
  • 148
  • 187
jakson
  • 325
  • 2
  • 4
  • 12

1 Answers1

0
for /f "tokens=1-6 delims=:/- " %a in ('robocopy "|" . /njh^|find "|"') do echo %a-%b-%c-%d%e%f
MC ND
  • 69,615
  • 8
  • 84
  • 126
  • It should be passed to *.exe program as one of parameters. You cant pass "for ..." as parameter - one solution is to pass "file_%date%-%time:~0,2%%time:~3,2%%time:~6,2%", but I wan "0" instead of " " (space). – jakson Aug 29 '15 at 00:54
  • @jakson, The idea is not to use `exefile for /f ...`, but `for /b ..... exefile file_%a-%b-%c-%d%e%f`. In previous code replace the `echo` with the executable – MC ND Aug 29 '15 at 08:28