yd99zgb 发表于 2008-8-26 20:04:00

请问是不是FileFindFirstFile出的问题?如果是怎样解决?

请问是不是FileFindFirstFile出的问题?如果是怎样解决?


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

#Region ### START Koda GUI section ### Form=d:\my documents\a3\form1.kxf
$Form1_1 = GUICreate("小改名软件", 404, 188, 230, 149)
$Button1 = GUICtrlCreateButton("输入", 16, 24, 81, 33, 0)
$Button2 = GUICtrlCreateButton("输出", 16, 72, 81, 33, 0)
$Group1 = GUICtrlCreateGroup("请选择", 8, 8, 377, 105)
$Label1 = GUICtrlCreateLabel("请选择输入路径", 112, 32, 260, 17)
$Label2 = GUICtrlCreateLabel("请选技输出路径", 112, 72, 260, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("开始", 48, 136, 105, 33, 0)
$Button4 = GUICtrlCreateButton("退出", 224, 136, 113, 33, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

                Case $Button1
                        $path1 = FileSelectFolder("请选择输入文件夹:", "")
                        $Label1 = GUICtrlCreateLabel($path1, 112, 32, 260, 17)
                       
                       
                Case $Button2
                        $path2 = FileSelectFolder("请选择输出文件夹:", "")
                        $Label2 = GUICtrlCreateLabel($path2, 112, 72, 260, 17)
                       
                Case $Button3
                        rename ()
                       
                       
                       
                Case $Button4
                        Exit
        EndSwitch
WEnd


func rename ()
        $search = FileFindFirstFile($path1&"\*.jpg")

; 检查搜索是否成功
If $search = -1 Then
    MsgBox(0, "错误", "无任何文件或文件夹与指定的搜索字符串匹配")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
   
       
        $t =FileGetTime($file, 1)
    $file2 = $t & "年" & $t & "月" & $t&"日_"&$t&"点"&$t&"分"&$t&"秒"
    MsgBox(0, $file&"改成了 ", $file2)
    FileCopy($path1&"\"&$file, $path2&"\"&$file2&".jpg")
       
       
       
WEnd

; 关闭搜索句柄
FileClose($search)

       
       
       
EndFunc

yd99zgb 发表于 2008-8-26 20:06:15

发现如果在程序当前目录改名就不会出错。。不知怎样解决。。。

clonecd 发表于 2008-8-26 22:42:48

用3.2.13.7版无任何问题

yd99zgb 发表于 2008-8-27 07:18:09

原帖由 clonecd 于 2008-8-26 22:42 发表 http://www.autoitx.com/images/common/back.gif
用3.2.13.7版无任何问题
我用的就是3.2.13.7.1版。。。。。
页: [1]
查看完整版本: 请问是不是FileFindFirstFile出的问题?如果是怎样解决?