#NoTrayIcon
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <Misc.au3>
#include <File.au3>
#include <StaticConstants.au3>
#include <GuiButton.au3>
If _Singleton(@ScriptName, 1) = 0 Then
MsgBox(64, "警告!", "您只能运行一个此应用程序!")
Exit (1)
EndIf
;GUI开始
$form = GUICreate("文本批量合成器", 500, 250)
GUISetBkColor(0xCCCCFF)
$Button1 = GUICtrlCreateButton("读取目录", 370, 10, 100, 28, 0)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
GUICtrlSetColor(-1, 0x009933)
$Button2 = GUICtrlCreateButton("写入目录", 370, 55, 100, 28, 0)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
GUICtrlSetColor(-1, 0x009933)
$Button3 = GUICtrlCreateButton("保存目录", 370, 100, 100, 28, 0)
GUICtrlSetFont(-1, 12, 400, 0, "黑体")
GUICtrlSetColor(-1, 0x009933)
$Button4 = GUICtrlCreateButton("开始合成", 370, 165, 108, 45, 0)
GUICtrlSetFont(-1, 14, 400, 0, "楷体_GB2312")
GUICtrlSetColor(-1, 0x0000FF)
$input1 = GUICtrlCreateInput("", 28, 10, 310, 28)
$input2 = GUICtrlCreateInput("", 28, 55, 310, 28)
$input3 = GUICtrlCreateInput("", 28, 100, 310, 28)
;$btn = GUICtrlCreateButton("开 始 生 成", 33, 112, 176, 25)
$label3 = GUICtrlCreateLabel("温馨提示:读取目录里的文件内容将被写入到写入目录里的同名文本的末尾!", 38, 145, 239, 80)
GUICtrlSetFont(-1, 11, 400, 0, "黑体")
GUICtrlSetColor(-1, 0x110000)
GUISetState(@SW_SHOW)
;$var = FileSelectFolder("选择一个文件夹.", "")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$read = FileSelectFolder("选择要读取的文件夹", "")
GUICtrlSetData($input1,$read)
GUICtrlSetColor($input1, 0xFF0433)
$duqu=GUICtrlRead($input1)
;MsgBox(0,"",$duqu)
Case $Button2
$write = FileSelectFolder("选择要写入的文件夹", "")
GUICtrlSetData($input2,$write)
GUICtrlSetColor($input2, 0xFF0433)
$xieru=GUICtrlRead($input2)
Case $Button3
$save = FileSelectFolder("选择要保存的文件夹", "")
GUICtrlSetData($input3,$save)
GUICtrlSetColor($input3, 0xFF0433)
$baocun=GUICtrlRead($input3)
Case $Button4
GUICtrlSetState($Button4, $GUI_DISABLE)
$label3 = GUICtrlCreateLabel("正在合成,请勿关闭....", 38, 190, 270, 20)
GUICtrlSetFont(-1, 11, 400, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0433)
FileCopy($xieru & "\*.*",$baocun,9)
start($duqu)
EndSwitch
WEnd
Func start($duqu)
Local $hSearch = FileFindFirstFile($duqu & "\*.*")
; 检查搜索是否成功
If $hSearch = -1 Then Return
While 1
Local $sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If @extended Then
start($duqu & "" & $sFile)
ContinueLoop
EndIf
$file1 = FileOpen($duqu & "" & $sFile, 0)
$file2 = FileOpen($baocun & "" & $sFile, 1)
Local $CountLines = _FileCountLines($duqu & "" & $sFile)
;MsgBox(0,"",$CountLines)
For $i=1 To $CountLines Step 1
Local $line = FileReadLine($file1,$i)
FileWrite($file2,@CRLF&$line)
If $i == $CountLines Then ExitLoop
Next
FileClose($file1)
FileClose($file2)
WEnd
FileClose($hSearch)
GUICtrlSetState($Button4, $GUI_ENABLE)
$label3 = GUICtrlCreateLabel("合成完毕,请及时查看!", 38, 190, 270, 20)
GUICtrlSetFont(-1, 11, 400, 0, "黑体")
GUICtrlSetColor(-1, 0xFF0433)
EndFunc
自己写的,可能效率很低,错误判断未设置,具体思路是: