How to get the most recent file using a batch file?

后端 未结 3 1843
难免孤独
难免孤独 2020-12-10 02:34

I have a list of zip files with date and time appended like yyyymmdd_hhmmss_Demos.zip. Now how to get the most recently added zip file in the source dir. I need

相关标签:
3条回答
  • 2020-12-10 02:50
    pushd \\ryap\CONTROL_DATOS
    for /f "tokens=*" %%a in ('dir \\ryap\CONTROL_DATOS /b /od') do set newest=%%a
    Xcopy/Y "\\ryap\CONTROL_DATOS\%newest%" "D:\TXT_SOURCES\"
    popd
    
    0 讨论(0)
  • 2020-12-10 02:54

    You can use

    pushd D:\a
    for /f "tokens=*" %%a in ('dir /b /od') do set newest=%%a
    copy "%newest%" D:\b
    popd
    
    0 讨论(0)
  • 2020-12-10 03:03
    set Path="D:\hello\abc\old"
    for /f "tokens=*" %%a in ('dir /A:-D /B /O:-D /S %Path%') do set NEW=%%a&& goto:n 
    :n
    echo %NEW%
    
    0 讨论(0)
提交回复
热议问题