#AutoIt3Wrapper_Icon=1.ICO
#include <File.au3>
#include <Array.au3>
Local $localpath,$netpath,$time
$mark = "复制文件"
If WinExists($mark) Then Exit
AutoItWinSetTitle($mark)
$message = "请选择要拷贝的文件"
$netpath = FileOpenDialog($message, "c:", "所有文件(*.*)", 1 + 4 )
If @error Then
MsgBox(4096,"","没有选中任何文件。")
Exit
EndIf
$dir = FileSelectFolder("请选择存放的文件夹:", "",1)
If StringRight($dir, 1) <> "" Then
$localpath = $dir & ""
Else
$localpath = $dir
EndIf
$time = InputBox("文件复制v2.0", @CRLF & "输入复制文件时间间隔" & @CRLF & @CRLF & "单位:分钟"& @CRLF &"例如:30", "") ;
If StringRight($time, 1) = "" Then
$time = 30
EndIf
$times = $time * 60 * 1000
GUISetState(@SW_SHOW)
While 1
copy_1()
Sleep($times)
WEnd
Func copy_1()
TrayTip("文件复制", "开始运行...", 1,1)
Sleep(1000)
_FileWriteLog(@ScriptDir & "\copy.log","[开始拷贝]")
Sleep(3000)
FileCopy($netpath,$localpath,9)
$arrs = StringSplit ( $netpath, "")
$file_1 = _ArrayPop ( $arrs )
$text = StringReplace($netpath, $file_1, "")
$temp = @MON&@MDAY&@HOUR&@MIN&@SEC
Sleep(3000)
If FileExists($localpath&"备份"&"_"&$file_1) Then
FileMove($localpath&$file_1,$localpath&$temp&"_"&$file_1)
Else
FileMove($localpath&$file_1,$localpath&"备份"&"_"&$file_1)
EndIf
Sleep(1000)
_FileWriteLog(@ScriptDir & "\copy.log","[结束拷贝]")
Sleep(1000)
_FileWriteLog(@ScriptDir & "\copy.log","[开始返回拷贝]")
Sleep(1000)
FileCopy($localpath&"备份"&"_"&$file_1,$text,1)
Sleep(1000)
_FileWriteLog(@ScriptDir & "\copy.log","[结束返回拷贝]")
Sleep(1000)
_FileWriteLog(@ScriptDir & "\copy.log","---------------------------------------------------------")
EndFunc
就是 把1个文件拷贝到 1个文件夹 然后在从这个文件夹拷贝到 原来的位置。 用于测试各盘之间的通讯。
但是 老是报错 有的时候 拷贝2个来回报错 有的时候3个来回。。不一定。。 |