找回密码
 加入
搜索
查看: 13356|回复: 21

[系统综合] 路径A文件夹的内容压缩打包复制到B文件夹以系统时间命名[已经解决]

 火.. [复制链接]
发表于 2012-2-8 14:38:19 | 显示全部楼层 |阅读模式
本帖最后由 bhffhzh 于 2012-2-9 21:26 编辑
 
#Include <date.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ComboConstants.au3>
#include <WindowsConstants.au3>
#include <ProgressConstants.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\administrator\桌面\备份器4.kxf
$save = "0"
$open = "0"
$Form1 = GUICreate("数据备份器", 465, 254, 303, 201,-1,-1)
 $Group1 = GUICtrlCreateGroup("", 16, 24, 425, 129)
$Label1 = GUICtrlCreateLabel("源 路 径:", 40, 72, 72, 24)
GUICtrlSetColor(-1, 0x800080)
$input = GUICtrlCreateInput("", 128, 72, 161, 24);源路径输入框
$Button1 = GUICtrlCreateButton("浏览", 328, 72, 51, 25)
$Label2 = GUICtrlCreateLabel("复 制 到:", 40, 115, 72, 24)
GUICtrlSetColor(-1, 0x800080)
$Input1 = GUICtrlCreateInput("", 128, 114, 161, 24)
$Button4 = GUICtrlCreateButton("浏览", 328, 117, 51, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1);目录路径输入框
$Button2 = GUICtrlCreateButton("复 制", 128, 192, 59, 25)
$Button3 = GUICtrlCreateButton("退 出", 240, 192, 59, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
        Case $Button1
           $save = FileSelectFolder("请选择要复制的文件夹:", "")
     GUICtrlSetData($input, $save)
  Case $Button4
       $open = FileSelectFolder("复制到:", "", 1)
       GUICtrlSetData($Input1, $open)
  Case $Button2
   
   
   ;;;;;;;;;;;;;;;;这里代码如何写;;;;;;;;;;;;;;;;;;;;;;
   
 
 EndSwitch
WEnd
 
 
另外代码有几个变量采取了别人的。顺便问一下
$save = "0"
$open = "0"
有什么作用

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-2-8 16:15:36 | 显示全部楼层
路过,进来看看谢谢。
发表于 2012-2-8 16:16:36 | 显示全部楼层
貌似自定义初始化。。。
发表于 2012-2-8 16:47:42 | 显示全部楼层
你这需要修改地方太多 基本就等于做了个界面  代码中就没出现错误处理  
你是不是做个选择到的文件用7Z打包 复制到另外的地方  如果这样的话 基本上代码可以全抛弃了
 楼主| 发表于 2012-2-8 18:00:08 | 显示全部楼层
你这需要修改地方太多 基本就等于做了个界面  代码中就没出现错误处理  
你是不是做个选择到的文件用7Z打 ...
shenrenba 发表于 2012-2-8 16:47



就调用系统的WINRAR
发表于 2012-2-8 20:15:34 | 显示全部楼层
就调用系统的WINRAR
bhffhzh 发表于 2012-2-8 18:00

那不如用7z的命令行7za,就一个文件不到600KB,功能很强。
发表于 2012-2-8 21:07:32 | 显示全部楼层
此帖我已经在我那边回答过你了:http://sky123.org/thread-181248-1-1.html

1、改了一下程序:


2、压缩打包:


3、打包后的程序:



#Region
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=n
#EndRegion

Opt("MustDeclareVars", 1)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include "7Zip.au3"

Global $gu_Form1 = GUICreate("数据备份器", 363, 112, -1, -1)
Global $gu_Group1 = GUICtrlCreateGroup("", 8, 0, 345, 73)
Global $gu_Label1 = GUICtrlCreateLabel("源路径", 16, 18, 40, 17)
Global $gu_Label2 = GUICtrlCreateLabel("打包至", 16, 42, 40, 17)
Global $gu_Input1 = GUICtrlCreateInput("", 56, 16, 249, 21)
Global $gu_Input2 = GUICtrlCreateInput("", 56, 40, 249, 21)
Global $gu_Button1 = GUICtrlCreateButton("..", 312, 16, 33, 17)
Global $gu_Button2 = GUICtrlCreateButton("..", 312, 40, 33, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $gu_Button3 = GUICtrlCreateButton("打包", 248, 80, 49, 25)
Global $gu_Button4 = GUICtrlCreateButton("退出", 304, 80, 49, 25)
GUISetState(@SW_SHOW)

_Main()
Exit

Func _Main()
        Local $r
        Local $nMsg

        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE, $gu_Button4
                                Exit
                        Case $gu_Button1
                                $r = ""
                                $r = FileSelectFolder("源路径", "", 2, "", $gu_Form1)
                                If $r <> "" And $r <> GUICtrlRead($gu_Input1) Then
                                        GUICtrlSetData($gu_Input1, $r)
                                EndIf
                        Case $gu_Button2
                                $r = ""
                                $r = FileSelectFolder("打包至", "", 2, "", $gu_Form1)
                                If $r <> "" And $r <> GUICtrlRead($gu_Input2) Then
                                        GUICtrlSetData($gu_Input2, $r)
                                EndIf
                        Case $gu_Button3
                                _Compress(GUICtrlRead($gu_Input1), GUICtrlRead($gu_Input2))
                EndSwitch
        WEnd

EndFunc   ;==>_Main

Func _Compress($Src, $Dest)
        If Not (FileExists($Src)) Then Return 0
        
        If Not (FileExists($Dest)) Then DirCreate($Dest)
        If Not (FileExists($Dest)) Then Return 0
        
        Local $PkgName = @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & ".7z"
        Local $sArcName = $Dest & "\" & $PkgName
        
        Local $sFileName = $Src & "\*"
        
        Local $r = _7ZipAdd($gu_Form1, $sArcName, $sFileName, 0, 9, 1, 0, 0, 0, 0, 0, 0)
        
        Return 1
EndFunc   ;==>_Compress


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +30 收起 理由
afan + 30

查看全部评分

发表于 2012-2-8 21:18:32 | 显示全部楼层
回复 8# skyfree


膜拜,S大出手就是不一样
发表于 2012-2-8 22:05:08 | 显示全部楼层
标志一下,以后备用
发表于 2012-2-9 08:20:04 | 显示全部楼层
进来学习一下
发表于 2012-2-9 08:54:17 | 显示全部楼层
高手终于现身了
发表于 2012-2-9 10:01:47 | 显示全部楼层
进来学习一下
 楼主| 发表于 2012-2-9 10:58:17 | 显示全部楼层
本帖最后由 bhffhzh 于 2012-2-9 11:00 编辑

S大。如果改成用系统自带的WINRAR来解决又如何写命令呢,?
也就是:                        Case $gu_Button3
                                _Compress(GUICtrlRead($gu_Input1), GUICtrlRead($gu_Input2))

这地方变成:
RunWait('C:\Program Files\WinRAR\winrar.exe  -ag -k -r -s -ibck    *********)

这星号地方琢磨了几天都没搞定。


自己吓搞了几下不行,提示

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-2-9 13:19:41 | 显示全部楼层
这个挺好写的不是
发表于 2012-2-9 19:18:00 | 显示全部楼层
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Process.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("数据备份器", 509, 291, -1, -1)
$Group1 = GUICtrlCreateGroup("", 40, 32, 425, 145)
$Label1 = GUICtrlCreateLabel("源路径:", 71, 74, 43, 20)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("复制到:", 71, 122, 43, 20)
GUICtrlSetFont(-1, 11, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("浏览", 368, 72, 75, 25)
$Button2 = GUICtrlCreateButton("浏览", 368, 120, 75, 25)
$Input1 = GUICtrlCreateInput("", 120, 74, 233, 21)
$Input2 = GUICtrlCreateInput("", 120, 122, 233, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("打包", 120, 224, 75, 25)
$Button4 = GUICtrlCreateButton("退出", 312, 224, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        $r = ""
                        $r = FileSelectFolder("源路径:", "", 2, "", $Form1)
                        If $r <> "" And $r <> GUICtrlRead($Input1) Then
                                GUICtrlSetData($Input1, $r)
                        EndIf
                Case $Button2
                        $r = ""
                        $r = FileSelectFolder("打包至:", "", 2, "", $Form1)
                        If $r <> "" And $r <> GUICtrlRead($Input2) Then
                                GUICtrlSetData($Input2, $r)
                        EndIf
                Case $Button3
                        _pack()
                Case $Button4
                        Exit
        EndSwitch
WEnd

Func _pack()
                $r1 = GUICtrlRead($Input1)
                $r2 = GUICtrlRead($Input2)
                If $r1 = "" Or $r2 = "" Then 
                       MsgBox(0+262144, '提示:', '请重新选择文件!') 
                Else
                       $name = @YEAR & @MON & @MDAY & '_' & @HOUR & @MIN & @SEC
                       _RunDOS('"7z.EXE" a -tzip -r '& $r2 & "" & $name & ".rar" &' '& $r1)
                       $m = MsgBox(1+64+262144, '提示:', '打包成功' & @CRLF & '是否打开压缩文件目录?')
                       If $m = 1 Then ShellExecute($r2)                 
                EndIf
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-17 06:12 , Processed in 0.090086 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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