assign date and time to output file

前端 未结 1 769
误落风尘
误落风尘 2021-01-24 13:50

i am working on ffmpeg screen capture and i wan\'t it to start recording on start up, so i need to give the output video file a name that is different every time i

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-24 14:46

    **edited to separate date and time with _

    If you only need it for unique filenames, don't mess around with the special chars and localized format. You can use:

    for /f "tokens=2 delims==" %%i in ('wmic os get localdatetime /value') do set DateTime=%%i
    set DateTime=%DateTime:~0,8%_%DateTime:~8,6%
    REM or:    set filename=%DateTime:~0,8%_%DateTime:~8,6%.flv
    echo %DateTime%
    

    EDIT to "the problem is the file name is like this 20140204_161529 and i wan't it to be like that 2014_02_04_16_15_29" : Use this inside the forloop:

    set oldfilename=%DateTime:~0,8%_%DateTime:~8,6%.flv
    set newfilename=%DateTime:~0,4%_%DateTime:~4,2%_%DateTime:~6,2%_%DateTime:~8,2%_%DateTi‌​me:~10,2%_%DateTime:~12,2%.flv
    

    0 讨论(0)
提交回复
热议问题