找回密码
 加入
搜索
查看: 3940|回复: 4

[原创] 文件区分工具(驱动文件,补丁文件,其他一切资料文件的区别)

[复制链接]
发表于 2013-1-30 11:03:38 | 显示全部楼层 |阅读模式
#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_Icon=C:\WINDOWS\system32\SHELL32.dll
#AutoIt3Wrapper_Outfile=区分并选出不同文件.exe
#AutoIt3Wrapper_Res_Comment=俞氏设计的一个粗陋的文本比较程序,让程序员从大量的文件管理中获得解放。
#AutoIt3Wrapper_Res_Description=1.0.0.1
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/rel
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
_main()
Exit
Func _main()
Local $aFile,$bFile,$cFile,$dFile,$Combo_val
$Form1_1 = GUICreate("区分并选出不同文件", 623, 151, 313, 275)
$Label1 = GUICtrlCreateLabel("源文件", 27, 34, 40, 17)
$Label2 = GUICtrlCreateLabel("比较文件", 27, 65, 52, 17)
$Label3 = GUICtrlCreateLabel("目标文件", 27, 97, 52, 17)
$Input1 = GUICtrlCreateInput("", 83, 29, 473, 21)
$Input2 = GUICtrlCreateInput("", 83, 61, 473, 21)
$Input3 = GUICtrlCreateInput("", 82, 93, 474, 21)
$Button1 = GUICtrlCreateButton("...", 563, 29, 35, 20)
$Button2 = GUICtrlCreateButton("...", 563, 61, 35, 20)
$Button3 = GUICtrlCreateButton("...", 562, 93, 36, 20)
$Button4 = GUICtrlCreateButton("确定", 293, 125, 76, 20)
$Button5 = GUICtrlCreateButton("取消", 381, 125, 76, 20)
$Combo1 = GUICtrlCreateCombo("请选择比较方案", 141, 125, 146, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "不同的源文件=>目标文件|不同的比较文件=>目标文件|不同的Both=>目标文件")
$Label4 = GUICtrlCreateLabel("默认根据文件名比较", 28, 5, 112, 17)
GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1 
                        _FileSelectFolder($Input1)
                Case $Button2
                        _FileSelectFolder($Input2)
                Case $Button3
                        _FileSelectFolder($Input3)
                Case $Button4 ;确定按键
                        $Combo_val=GUICtrlRead($Combo1)
                        $aFile=GUICtrlRead($Input1)
                        $bFile=GUICtrlRead($Input2)
                        $dFile=GUICtrlRead($Input3)
;~                         MsgBox(0,"",$Combo_val,3)
                        Switch $Combo_val
                                Case "请选择比较方案"
                                        MsgBox(0,"提示","您还未选择复制方案",3)
                                Case "不同的源文件=>目标文件"
                                        $cFile=_FileDef($aFile,$bFile,2)
                                        For $i=1 To UBound($cFile)-1
                                                _FileCopy($aFile&""&$cFile[$i],$dFile)
                                        Next
                                        MsgBox(0,"任务结束","已复制"&UBound($cFile)-1&"个文件,确定退出")
                                Case "不同的比较文件=>目标文件"
                                        $cFile=_FileDef($aFile,$bFile,3)
                                        For $i=1 To UBound($cFile)-1
                                                _FileCopy($bFile&""&$cFile[$i],$dFile)
                                        Next
                                        MsgBox(0,"任务结束","已复制"&UBound($cFile)-1&"个文件,确定退出")
                                Case "不同的Both=>目标文件"
                                        $cFile=_FileDef($aFile,$bFile,1)
                                        For $i=1 To UBound($cFile)-1
                                                _FileCopy($aFile&""&$cFile[$i],$dFile)
                                                _FileCopy($bFile&""&$cFile[$i],$dFile)
                                        Next
                                        MsgBox(0,"任务结束","已复制"&UBound($cFile)-1&"个文件,确定退出")
                                Case Else
                                        MsgBox(0,"警告","未选择相应的比较模式",3)
                        EndSwitch
                Case $Button5
                        Exit
        EndSwitch
WEnd
EndFunc ;==>_main()

Func _FileSelectFolder($Input)
        Dim $FolderPath
        $FolderPath=FileSelectFolder("请选择文件所在目录","c:")
        GUICtrlSetData($Input,$FolderPath,"")
EndFunc ;==>_FileSelectFolder()
Func _FileDef($aFile,$bFile,$val)
        Dim $str_aFile,$str_bFile
        Dim $str_cFile[1],$p=1
        Dim $i,$j
        $str_aFile=_FileListToArray($aFile)
        $str_bFile=_FileListToArray($bFile)
        If IsArray($str_aFile)=0 And IsArray($str_bFile)=0 Then Return SetError(1, 0, -1)
        Switch $val
                Case 1 ;both
                        If IsArray($str_aFile)=0 And IsArray($str_bFile) Then 
                                For $i=1 To UBound($str_bFile)-1
                                        ReDim $str_cFile[$p+1]
                                        $str_cFile[$p]=$str_bFile[$i]
                                        $p+=1
                                Next
                        EndIf
                        If IsArray($str_aFile) And IsArray($str_bFile)=0 Then
                                For $i=1 To UBound($str_aFile)-1
                                        ReDim $str_cFile[$p+1]
                                        $str_cFile[$p]=$str_aFile[$i]
                                        $p+=1
                                Next
                        EndIf
                        If IsArray($str_aFile) And IsArray($str_bFile) Then
                                For $i=1 To UBound($str_aFile)-1
                                        For $j=1 To UBound($str_bFile)-1
                                                If $str_aFile[$i]=$str_bFile[$j] Then 
                                                        $str_aFile[$i]=""
                                                        $str_bFile[$j]=""
                                                EndIf
                                        Next
                                Next
                                For $i=1 To UBound($str_aFile)-1
                                        If $str_aFile[$i]<>"" Then 
                                                ReDim $str_cFile[$p+1]
                                                $str_cFile[$p]=$str_aFile[$i]
                                                $p+=1
                                        EndIf
                                Next
                                For $i=1 To UBound($str_bFile)-1
                                        If $str_bFile[$i]<>"" Then
                                                ReDim $str_cFile[$p+1]
                                                $str_cFile[$p]=$str_bFile[$i]
                                                $p+=1
                                        EndIf
                                Next
                        EndIf
                Case 2 ;源文件到目标
                        If IsArray($str_aFile)=0 Then 
                                MsgBox(0,"提示","源文件为空文件夹",3)
                        EndIf
                        If IsArray($str_aFile) And IsArray($str_bFile)=0 Then
                                For $i=1 To UBound($str_aFile)-1
                                        ReDim $str_cFile[$p+1]
                                        $str_cFile[$p]=$str_aFile[$i]
                                        $p+=1
                                Next
                        EndIf
                        If IsArray($str_aFile) And IsArray($str_bFile) Then
                                For $i=1 To UBound($str_aFile)-1
                                        For $j=1 To UBound($str_bFile)-1
                                                If $str_aFile[$i]=$str_bFile[$j] Then 
                                                        $str_aFile[$i]=""
                                                EndIf
                                        Next
                                Next
                                For $i=1 To UBound($str_aFile)-1
                                        If $str_aFile[$i]<>"" Then 
                                                ReDim $str_cFile[$p+1]
                                                $str_cFile[$p]=$str_aFile[$i]
                                                $p+=1
                                        EndIf
                                Next
                        EndIf
                Case 3 ;比较文件到目标
                        If IsArray($str_aFile)=0 And IsArray($str_bFile) Then 
                                For $i=1 To UBound($str_bFile)-1
                                        ReDim $str_cFile[$p+1]
                                        $str_cFile[$p]=$str_bFile[$i]
                                        $p+=1
                                Next
                        EndIf
                        If IsArray($str_bFile)=0 Then
                                MsgBox(0,"提示","比较文件为空文件夹",3)
                        EndIf
                        If IsArray($str_aFile) And IsArray($str_bFile) Then
                                For $i=1 To UBound($str_aFile)-1
                                        For $j=1 To UBound($str_bFile)-1
                                                If $str_aFile[$i]=$str_bFile[$j] Then 
                                                        $str_bFile[$j]=""
                                                EndIf
                                        Next
                                Next
                                For $i=1 To UBound($str_bFile)-1
                                        If $str_bFile[$i]<>"" Then
                                                ReDim $str_cFile[$p+1]
                                                $str_cFile[$p]=$str_bFile[$i]
                                                $p+=1
                                        EndIf
                                Next
                        EndIf
                Case Else
                        MsgBox(0,"提示","您输入的比较模式参数错误",3)
        EndSwitch
        Return $str_cFile
EndFunc ;==>_FileDef()
Func _FileCopy($aFile,$bFile)
        FileCopy($aFile,$bFile)
EndFunc ;==>_FileCopy()
发表于 2018-11-6 06:03:27 | 显示全部楼层
谢谢分享,学习学习
发表于 2018-2-25 19:26:49 | 显示全部楼层
谢谢楼主分享!!
发表于 2018-2-10 18:48:26 | 显示全部楼层
不错,谢谢分享!
发表于 2017-1-26 02:43:26 | 显示全部楼层
不错的工具能有源码支持楼主
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-18 22:12 , Processed in 0.072361 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表