回复 3# netdzb - @echo off & setlocal enabledelayedexpansion & rem title by author Gan
- set "t_path=E:\123\"
- set /a count = 0
- ::搜索的%t_path%目录下所有的txt文件
- for /f %%a in ('where /f /r %t_path% "*.txt"') do (set "count_file_!count!=%%a" & set /a count+=1)
-
- ::生成小于txt文件总数的随机数(效率和文件数成反比)
- ::优化好了发出来看看
- echo;正在打开随机文件请稍后...
- echo;
- :loop
- set /a temp = 1
- for /l %%a in (1,1,%temp%) do (set /a ran = %random%
- if !ran! leq %count% goto :break1
- goto :loop)
-
- :break1
- type !count_file_%ran%!
-
- pause
复制代码 你试试!! |