#Include <Array.au3>
Global $way="D:\UserFile\Desktop\连接\3"
Dim $array1[1],$array2[1]
Local $search = FileFindFirstFile($way&"*.txt")
; 检查搜索是否成功
If $search = -1 Then
MsgBox(0, "错误", "没有文件/目录 匹配搜索")
Exit
EndIf
Local $file = FileFindNextFile($search)
$d=StringRegExp($file,'\d+',1)
If Not @error Then
$array1[0]=$file
$array2[0]=$d[0]
EndIf
Dim $k=1
While 1
Local $file = FileFindNextFile($search)
If @error Then ExitLoop
$d=StringRegExp($file,'\d+',1)
If Not @error Then
_ArrayAdd($array1,$file)
_ArrayAdd($array2,$d[0])
;MsgBox(0,$file,$d[0])
EndIf
WEnd
;_ArrayDisplay($array)
;_ArrayDisplay($array2)
; 关闭搜索句柄
FileClose($search)
Global $array[UBound($array1)][2]
For $i=0 To UBound($array)-1
$array[$i][0]=$array1[$i]
$array[$i][1]=$array2[$i]
Next
_ArraySort ($array,0,0,0,1)
;_ArrayDisplay($array)
$newfile=FileOpen($way&"合并后.txt",9)
For $i=0 To UBound($array)-1
$str=FileRead($way&$array[$i][0])
FileWrite($newfile,$str&@CRLF)
Next
MsgBox(0,"","合并结束")
|