Batch List files in folder and subfolder according to specific format

前端 未结 1 895
予麋鹿
予麋鹿 2021-01-16 18:47

I am having an question Is it possible to make an batch file that read the dir and subdirs and output the results in an specific format into an .txt file?

I know how

相关标签:
1条回答
  • 2021-01-16 19:52

    EDIT: Small modifications as reply to the comments.

    The following two points have been modified:

    • Convert date from DD-MM-YYYY to YYYY-MM-DD.
    • Minor adjustments in the output format.

    .

    @echo off
    setlocal EnableDelayedExpansion
    
    set "base=%CD%"
    set "base=%base:*:=%\"
    
    for /R %%a in (*.*) do (
       for /F "tokens=1-5 delims=/-. " %%b in ("%%~Ta") do set "dateTime=%%d-%%c-%%b  %%e%%f"
       set "size=                   %%~Za"
       set name=%%~PNXa
       echo !dateTime! !size:~-19! !name:%base%=!
    )
    
    0 讨论(0)
提交回复
热议问题