Put command output into a variable

前端 未结 4 1640
耶瑟儿~
耶瑟儿~ 2021-01-24 03:27

Given a directory with the following files

image1.txt
image2.txt
image3.txt

I want to get the oldest file (let the files be sorted by data, old

4条回答
  •  攒了一身酷
    2021-01-24 03:40

    There isn't a direct way, the FOR-Loop is one way or the other way is set /p with a temporary file.

    dir /b /od c:\test\image?.txt | findstr ^1 > oldest.tmp
    < oldest.tmp set /p myVar=
    

提交回复
热议问题