简体   繁体   English

输出文件中文件名的排序

[英]Sorting of filenames in the output file

I would like to know how to write output of numeric filenames (0.mp4,1.mp4...10.mp4,11.mp4) residing in a folder along with the path to an output text file in ascending order. 我想知道如何编写驻留在文件夹中的数字文件名(0.mp4,1.mp4 ... 10.mp4,11.mp4)的输出以及输出文本文件的路径升序排列。 While I am able to write the output to the text file using the below batch script, the order of the file names in the output file is not sorted 虽然我可以使用以下批处理脚本将输出写入文本文件,但是输出文件中文件名的顺序未排序

for /r %f in (*.mp4) do echo %f >>out.txt

gives me the out.txt as 给我的out.txt为

0.mp4
1.mp4
10.mp4
11.mp4

I need it as 我需要它

0.mp4
1.mp4
2.mp4,
3.mp4 etc

.

Please help. 请帮忙。

you can do a recursive ascending dir list and then do whatever you need to do, including printing to a file: 您可以执行递归的升序目录列表​​,然后执行所需的任何操作,包括打印到文件:

for /f "tokens=1* delims=" %%m in ('dir /b /o:n /s ^| findstr /i ".mp4"') do (
    echo %%m>>out.txt
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM