找回密码
 加入
搜索
楼主: xavier880819

使用autoIT调用bat文件的问题

[复制链接]
发表于 2009-8-11 17:26:47 | 显示全部楼层
本帖最后由 afan 于 2009-8-11 18:16 编辑

插入了你需要的部分(红色),慢慢调试吧,呵呵

Func scml()
        $ymlr = GUICtrlRead($yml)
        $fh = FileOpen(@ScriptDir & "\1.txt", 1)
        _filelist($ymlr, '.mp3')
        FileClose($fh)
        $fh = FileOpen(@ScriptDir & "\1.txt", 0)

        $gmlr = GUICtrlRead($gml)
        $sl1 = GUICtrlRead($s[1])
        If $gmlr = '' Then $gmlr = @ScriptDir
        For $i1 = 1 To $sl1
                $fn1 = 'MP3-'
                $xml1 = $gmlr & '\' & $fn1 & $i1
                DirCreate($xml1)
                While 1
                        $rl = FileReadLine($fh)
                        If @error = -1 Then ExitLoop
                        FileCopy($rl, $xml1, 9)
                WEnd

                $ywc = $ywc + 1
        Next
        FileClose($fh)
        FileDelete(@ScriptDir & "\1.txt")

EndFunc   ;==>scml

Func jdt()
        GUICtrlSetData($jdt, $ywc / $zs * 100)
        GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc   ;==>jdt

Func _filelist($searchdir, $hzm)
        $search = FileFindFirstFile($searchdir & "\*")
        If $search = -1 Then Return -1
        While 1
                $file = FileFindNextFile($search)
                If @error Then
                        FileClose($search)
                        Return
                ElseIf $file = "." Or $file = ".." Then
                        ContinueLoop
                ElseIf StringInStr(FileGetAttrib($searchdir & "\" & $file), "D") Then
                        _filelist($searchdir & "\" & $file, $hzm)
                        ContinueLoop
                EndIf
                If StringRight($file, 4) = $hzm Then
                        FileWriteLine($fh, $searchdir & "\" & $file)
                EndIf
        WEnd
EndFunc   ;==>_filelist
 楼主| 发表于 2009-8-11 18:07:22 | 显示全部楼层
好的,我去试试,谢谢你!!
 楼主| 发表于 2009-8-12 13:51:18 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#NoTrayIcon


$Form1 = GUICreate('Multi-Level Folder Creator', 387,265,-1,-1)
Dim $n = 1, $l[15], $s[15]
For $n = 1 To 14
        $l[$n] = GUICtrlCreateLabel("Lv" & $n, 12 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 18)
        $s[$n] = GUICtrlCreateInput("0", 45 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 17 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
        GUICtrlSetLimit(-1, 4)
                Next
$yml = GUICtrlCreateInput("", 11, 85, 240, 23)
$Button = GUICtrlCreateButton("Create Folder / Copy File", 10, 160, 220, 25)
$Button1 = GUICtrlCreateButton("Remove All", 240, 160, 135, 25)
$Button2 = GUICtrlCreateButton("Source File Folder", 255, 84, 120, 26)
$Button3 = HotKeySet("{ESC}", "Terminate")
$gml = GUICtrlCreateInput("",11,120,240,23)
$Button5 = GUICtrlCreateButton("Target Folder", 255, 119, 120, 26)
$xs = GUICtrlCreateLabel("0/0        ", 175, 220, 300, 15)
GUICtrlSetColor(-1, 0xff0000)
$jdt = GUICtrlCreateProgress(10, 200, 365, 12,$PBS_SMOOTH)
$jdf = GUICtrlCreateProgress(10, 240, 365, 12,$PBS_SMOOTH)
GUISetState()

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

                Case $Button
                        GUICtrlSetData($jdt, 0)
                        GUICtrlSetState($Button, $GUI_ENABLE)
                        Dim $ywc = 0, $zs = 0, $sc = 1,$f,$h
                        jc()
                        AdlibEnable("jdt")
                        If GUICtrlRead($s[1]) = 0 then
                                msgbox(16, 'Error', 'Please set the number of folders')
                                                        Else
                                                                $f=MsgBox(1+48,'Attention','You will create ' & $zs & ' folders.' &@CRLF& 'Do you wish to continue?')
                                                                Select
                                                                        Case $f=1
                                       scml()
                                                                           sleep(300)
                                       AdlibDisable()
                                       msgbox(64, 'Finish', 'Created  ' & $zs & '  Folders! ')
                                                                   Case $f=2
                                                                           ContinueLoop
                                                                   EndSelect  
                                                                                       
                                                                  EndIf
                                                                  GUICtrlSetState($Button,$GUI_ENABLE)
                                                        
                                                Case $Button1
                                        $h=MsgBox(1+48,'Attention','Are you sure you want to Delete all the folders ?')
                                        Select
                                                Case $h=1
                                             Del()
                                             sleep(300)
                                                 msgbox(64, 'Finish', 'You have deleted all the folders! ')
                                            Case $h=2
                                                ContinueLoop
                                                EndSelect
                                Case $Button2
                        $ywjj = FileSelectFolder("Choose The Folder", "", 4)
                        If @error Then ContinueLoop
                        GUICtrlSetData($yml, $ywjj)
                                        Case $Button3
                                        Terminate()
                                Case $Button5
                                        $ywxx = FileSelectFolder("Choose The Folder", "", 4)
                                        If @error Then ContinueLoop
                        GUICtrlSetData($gml, $ywxx)
                                        
        EndSwitch
WEnd

Func Del()
        Dim $num
        For $num = 1 To 1000
        $gmld = GUICtrlRead($gml)        
        DirRemove($gmld & '\' & 'MP3-'&$num,1)
        Next
        
        EndFunc
        
Func jc()
        For $i = 14 To 1 Step -1
                $sl = GUICtrlRead($s[$i])
                If $sl > 0 then
                        For $i1 = 1 To $i
                                $sl1 = GUICtrlRead($s[$i1])
                                If $sl1 = 0 then
                                        GUICtrlSetData($s[$i1], 1)
                                        $sl1 = 1
                                endif
                                $zs = $zs + ($sc * $sl1)
                                $sc = $sc * $sl1
                        Next
                        ExitLoop
                Endif
        Next
EndFunc   ;==>jc

Func Terminate()
   Exit 0
EndFunc
Func _filelist($searchdir, $hzm)
            $search = FileFindFirstFile($searchdir & "\*")
                If $search = -1 Then Return -1
        While 1
                $file = FileFindNextFile($search)
                If @error Then
                        FileClose($search)
                        Return
                ElseIf $file = "." Or $file = ".." Then
                        ContinueLoop
                ElseIf StringInStr(FileGetAttrib($searchdir & "" & $file), "D") Then
                        _filelist($searchdir & "" & $file, $hzm)
                        ContinueLoop
                EndIf
                If StringRight($file, 4) = $hzm Then
                FileWriteLine($fh, $searchdir & "" & $file)
                EndIf
        WEnd
EndFunc   ;==>_filelist
Func jdt()
        GUICtrlSetData($jdt, $ywc / $zs * 100)
        GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc   ;==>jdt
Func scml()
        $ymlr = GUICtrlRead($yml)
        $fh = FileOpen(@ScriptDir & "\1.txt", 1)
        _filelist($ymlr, '.mp3')
        FileClose($fh)
        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
        $gmlr = GUICtrlRead($gml)
        $sl1 = GUICtrlRead($s[1])
        If $gmlr = '' Then $gmlr = @ScriptDir
        For $i1 = 1 To $sl1
                $fn1 = 'MP3-'
                $xml1 = $gmlr & '\' & $fn1 & $i1
                DirCreate($xml1)
                While 1
                        $rl = FileReadLine($fh)
                        If @error = -1 Then ExitLoop
                        FileCopy($rl, $gmlr, 9)
                WEnd
                FileClose($fh)
                FileDelete(@ScriptDir & "\1.txt")
                                $ywc = $ywc + 1
                                Next
                EndFunc   ;==>scml
 楼主| 发表于 2009-8-12 13:56:26 | 显示全部楼层
afan,上面是一个较为完整的调试过后的程序了,但是一旦运行就会说在Func _filelist(112行)里面的  FileWriteLine($fh, $searchdir & "\" & $file)(127行)出错,说没有在变量没有在开始的时候定义,于是我就尝试在112行和113行之间加了个 $fh = FileOpen(@ScriptDir & "\1.txt",0),程序倒是可以运行了,但是却无法复制文件。
后来我又再仔细看看,觉得那样直接定义一个$fh的确不大对,因为这样定义了下面在Func scml()里面
的$fh可能就不知道怎么运行了,于是现在就被卡在这里了。
 楼主| 发表于 2009-8-12 13:56:48 | 显示全部楼层
afan,上面是一个较为完整的调试过后的程序了,但是一旦运行就会说在Func _filelist(112行)里面的  FileWriteLine($fh, $searchdir & "\" & $file)(127行)出错,说没有在变量没有在开始的时候定义,于是我就尝试在112行和113行之间加了个 $fh = FileOpen(@ScriptDir & "\1.txt",0),程序倒是可以运行了,但是却无法复制文件。
后来我又再仔细看看,觉得那样直接定义一个$fh的确不大对,因为这样定义了下面在Func scml()里面
的$fh可能就不知道怎么运行了,于是现在就被卡在这里了。
发表于 2009-8-12 14:32:22 | 显示全部楼层
本帖最后由 afan 于 2009-8-12 14:40 编辑

137行改为:
Global $fh = FileOpen(@ScriptDir & "\1.txt", 1)
或10行改为:
Dim $n = 1, $l[15], $s[15], $fh
另外,与此无关的 151行要改一下,不然都复制到外面了
FileCopy($rl, $xml1, 9)
 楼主| 发表于 2009-8-12 15:41:05 | 显示全部楼层
81# afan
Func scml()
        $ymlr = GUICtrlRead($yml)
        $fh = FileOpen(@ScriptDir & "\1.txt", 1)
        _filelist($ymlr, '.mp3')
        FileClose($fh)
        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
        $gmlr = GUICtrlRead($gml)
        $sl1 = GUICtrlRead($s[1])
        If $gmlr = '' Then $gmlr = @ScriptDir
                For $i1 = 1 To $sl1
                $fn1 = 'MP3-'
                $xml1 = $gmlr & '\' & $fn1 & $i1
                DirCreate($xml1)
                While 1
                            $rl = FileReadLine($fh)
                            If @error = -1 Then ExitLoop
                            FileCopy($rl, $xml1, 9)
                WEnd
                FileClose($fh)
                FileDelete(@ScriptDir & "\1.txt")
                                $ywc = $ywc + 1
                                $sl2 = GUICtrlRead($s[2])
                For $i2 = 1 To $sl2
                        $fn2 = $fn1 & $i1
                        $xml2 = $gmlr&'\'&$fn2 & '\' & $fn2 & '-' & $i2
                        DirCreate($xml2)
                        While 1
                        $rl = FileReadLine($fh)
                        If @error = -1 Then ExitLoop
                        FileCopy($rl, $xml2, 9)
                        WEnd
                        FileClose($fh)
                        FileDelete(@ScriptDir & "\1.txt")
                                            $ywc = $ywc + 1
但是很奇怪,和以前那个复制整个文件夹用相同的办法,到了第二层就停在那边复制不了了啊.......
发表于 2009-8-12 15:49:10 | 显示全部楼层
本帖最后由 afan 于 2009-8-12 18:02 编辑

FileDelete(@ScriptDir & "\1.txt")
这只在循环完所有的for...才出现
        FileClose($fh)
        FileDelete(@ScriptDir & "\1.txt")
EndFunc   ;==>scml
 楼主| 发表于 2009-8-12 17:45:02 | 显示全部楼层
83# afan

这样放好像还是不行,只能创建在第一层,后面的就不行了,我自己倒是用了一种办法,就是在每一层都加入fileopen,fileclose,deletefile,但是前面都能运行得好好的,到了第12层就出问题了。
$sl11 = GUICtrlRead($s[11])
                                                                                                                                                                                         For $i11 = 1 To $sl11
                                                                                                 $fn11 = $fn10 & '-' & $i10
                                                                                                 $xml11 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\' & $fn11 & '-' & $i11
                                                                                                                                                                                                 DirCreate($xml11)
                                                                                                                                                                                                 $fh = FileOpen(@ScriptDir & "\1.txt", 1)
                                                                                                                                                                                             _filelist($ymlr, '.mp3')
                                                                                                 FileClose($fh)
                                                                                                 $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                 While 1
                                                                                                             $rl = FileReadLine($fh)
                                                                                                             If @error = -1 Then ExitLoop
                                                                                                             FileCopy($rl, $xml11, 9)
                                                                                                 WEnd
                                                                                                 FileClose($fh)
                                                                                                                 FileDelete(@ScriptDir & "\1.txt")
                                                                                                 $ywc = $ywc + 1
                                                                                                                                                                                                 $sl12 = GUICtrlRead($s[12])
                                                                                                                                                                                                                  For $i12 = 1 To $sl12
                                                                                                          $fn12 = $fn11 & '-' & $i11
                                                                                                          $xml12 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\'& $fn12 & '\' & $fn12 & '-' & $i12
                                                                                                          DirCreate($xml12)
                                                                                                                                                                                                                  $fh = FileOpen(@ScriptDir & "\1.txt", 1)
                                                                                                                                                                                                                  _filelist($ymlr, '.mp3')
                                                                                                          FileClose($fh)
                                                                                                          $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                          While 1
                                                                                                                      $rl = FileReadLine($fh)
                                                                                                                      If @error = -1 Then ExitLoop
                                                                                                                      FileCopy($rl, $xml12, 9)
                                                                                                          WEnd
                                                                                                          FileClose($fh)
                                                                                                                          FileDelete(@ScriptDir & "\1.txt")
                                                                                                          $ywc = $ywc + 1
                                                                                                                                                                                                          $sl13 = GUICtrlRead($s[13])
                                                                                                                                                                                                                              For $i13 = 1 To $sl13
                                                                                                                  $fn13 = $fn12 & '-' & $i12
                                                                                                                  $xml13 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\'& $fn12 & '\'& $fn13 & '\' & $fn13 & '-' & $i13
                                                                                                                  DirCreate($xml13)
                                                                                                                                                                                                                                  $fh = FileOpen(@ScriptDir & "\1.txt", 1)
                                                                                                                  _filelist($ymlr, '.mp3')
                                                                                                                  FileClose($fh)
                                                                                                                  $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                  While 1
                                                                                                                              $rl = FileReadLine($fh)
                                                                                                                              If @error = -1 Then ExitLoop
                                                                                                                              FileCopy($rl, $xml13, 9)
                                                                                                                  WEnd
                                                                                                                  FileClose($fh)
                                                                                                                                  FileDelete(@ScriptDir & "\1.txt")
                                                                                                                  $ywc = $ywc + 1
而且好像用这种方式,当没有设定源文件夹的时候,程序就不能自动创建文件夹。
发表于 2009-8-12 18:07:42 | 显示全部楼层
本帖最后由 afan 于 2009-8-12 18:45 编辑

我83#多写了一行,应该是:
FileDelete(@ScriptDir & "\1.txt")
这只在循环完所有的for...才出现
        FileClose($fh)
        FileDelete(@ScriptDir & "\1.txt")
EndFunc   ;==>scml

While循环之前 $fh = FileOpen(@ScriptDir & "\1.txt", 0)
While循环完后 FileClose($fh)

最后 FileDelete(@ScriptDir & "\1.txt")
不用每层都 _filelist($ymlr, '.mp3')

btw,你建这么多层有必要么?... 10层我看都不实用了~
发表于 2009-8-12 20:57:34 | 显示全部楼层
不错,学习一下!
 楼主| 发表于 2009-8-13 09:19:11 | 显示全部楼层
85# afan


因为我确实可能会用到,所以才创建这么多,现在这样的确可以用了,但是出现了2个问题,和我之前那个方法遇到的一模一样。

1. 当文件夹到达12层以后就不会再创建了,也不复制文件了
2. 如果在源文件里面没有选择路径,以前是可以直接一层一层地创建空的文件夹,而现在这个功能却不能运行了。
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#NoTrayIcon


$Form1 = GUICreate('Multi-Level Folder Creator', 387,265,-1,-1)
Dim $n = 1, $l[15], $s[15],$fh
For $n = 1 To 14
        $l[$n] = GUICtrlCreateLabel("Lv" & $n, 12 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 18)
        $s[$n] = GUICtrlCreateInput("0", 45 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 17 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
        GUICtrlSetLimit(-1, 4)
                Next
$yml = GUICtrlCreateInput("", 11, 85, 240, 23)
$Button = GUICtrlCreateButton("Create Folder / Copy File", 10, 160, 220, 25)
$Button1 = GUICtrlCreateButton("Remove All", 240, 160, 135, 25)
$Button2 = GUICtrlCreateButton("Source File Folder", 255, 84, 120, 26)
$Button3 = HotKeySet("{ESC}", "Terminate")
$gml = GUICtrlCreateInput("",11,120,240,23)
$Button5 = GUICtrlCreateButton("Target Folder", 255, 119, 120, 26)
$xs = GUICtrlCreateLabel("0/0        ", 175, 220, 300, 15)
GUICtrlSetColor(-1, 0xff0000)
$jdt = GUICtrlCreateProgress(10, 200, 365, 12,$PBS_SMOOTH)
$jdf = GUICtrlCreateProgress(10, 240, 365, 12,$PBS_SMOOTH)
GUISetState()

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

                Case $Button
                        GUICtrlSetData($jdt, 0)
                        GUICtrlSetState($Button, $GUI_ENABLE)
                        Dim $ywc = 0, $zs = 0, $sc = 1,$f,$h
                        jc()
                        AdlibEnable("jdt")
                        If GUICtrlRead($s[1]) = 0 then
                                msgbox(16, 'Error', 'Please set the number of folders')
                                                        Else
                                                                $f=MsgBox(1+48,'Attention','You will create ' & $zs & ' folders.' &@CRLF& 'Do you wish to continue?')
                                                                Select
                                                                        Case $f=1
                                       scml()
                                                                           sleep(300)
                                       AdlibDisable()
                                       msgbox(64, 'Finish', 'Created  ' & $zs & '  Folders! ')
                                                                   Case $f=2
                                                                           ContinueLoop
                                                                   EndSelect  
                                                                                       
                                                                  EndIf
                                                                  GUICtrlSetState($Button,$GUI_ENABLE)
                                                        
                                                Case $Button1
                                        $h=MsgBox(1+48,'Attention','Are you sure you want to Delete all the folders ?')
                                        Select
                                                Case $h=1
                                             Del()
                                             sleep(300)
                                                 msgbox(64, 'Finish', 'You have deleted all the folders! ')
                                            Case $h=2
                                                ContinueLoop
                                                EndSelect
                                Case $Button2
                        $ywjj = FileSelectFolder("Choose The Folder", "", 4)
                        If @error Then ContinueLoop
                        GUICtrlSetData($yml, $ywjj)
                                        Case $Button3
                                        Terminate()
                                Case $Button5
                                        $ywxx = FileSelectFolder("Choose The Folder", "", 4)
                                        If @error Then ContinueLoop
                        GUICtrlSetData($gml, $ywxx)
                                        
        EndSwitch
WEnd

Func Del()
        Dim $num
        For $num = 1 To 1000
        $gmld = GUICtrlRead($gml)        
        DirRemove($gmld & '\' & 'MP3-'&$num,1)
        Next
        
        EndFunc
        
Func jc()
        For $i = 14 To 1 Step -1
                $sl = GUICtrlRead($s[$i])
                If $sl > 0 then
                        For $i1 = 1 To $i
                                $sl1 = GUICtrlRead($s[$i1])
                                If $sl1 = 0 then
                                        GUICtrlSetData($s[$i1], 1)
                                        $sl1 = 1
                                endif
                                $zs = $zs + ($sc * $sl1)
                                $sc = $sc * $sl1
                        Next
                        ExitLoop
                Endif
        Next
EndFunc   ;==>jc

Func Terminate()
   Exit 0
EndFunc
Func _filelist($searchdir, $hzm)
            $search = FileFindFirstFile($searchdir & "\*")
                If $search = -1 Then Return -1
        While 1
                $file = FileFindNextFile($search)
                If @error Then
                        FileClose($search)
                        Return
                ElseIf $file = "." Or $file = ".." Then
                        ContinueLoop
                ElseIf StringInStr(FileGetAttrib($searchdir & "" & $file), "D") Then
                        _filelist($searchdir & "" & $file, $hzm)
                        ContinueLoop
                EndIf
                If StringRight($file, 4) = $hzm Then
                FileWriteLine($fh, $searchdir & "" & $file)
                EndIf
        WEnd
EndFunc   ;==>_filelist
Func jdt()
        GUICtrlSetData($jdt, $ywc / $zs * 100)
        GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc   ;==>jdt
Func scml()
        $ymlr = GUICtrlRead($yml)
        $fh = FileOpen(@ScriptDir & "\1.txt", 1)
        _filelist($ymlr, '.mp3')
        FileClose($fh)
        $gmlr = GUICtrlRead($gml)
        $sl1 = GUICtrlRead($s[1])
        If $gmlr = '' Then $gmlr = @ScriptDir
                For $i1 = 1 To $sl1
                $fn1 = 'MP3-'
                $xml1 = $gmlr & '\' & $fn1 & $i1
                DirCreate($xml1)
                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                While 1
                            $rl = FileReadLine($fh)
                            If @error = -1 Then ExitLoop
                            FileCopy($rl, $xml1, 9)
                            WEnd
                            FileClose($fh)
                $ywc = $ywc + 1
                                $sl2 = GUICtrlRead($s[2])
                        For $i2 = 1 To $sl2
                        $fn2 = $fn1 & $i1
                        $xml2 = $gmlr&'\'&$fn2 & '\' & $fn2 & '-' & $i2
                        DirCreate($xml2)
                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                While 1
                        $rl = FileReadLine($fh)
                        If @error = -1 Then ExitLoop
                        FileCopy($rl, $xml2, 9)
                                            WEnd
                                            FileClose($fh)
                        $ywc = $ywc + 1
                                                $sl3 = GUICtrlRead($s[3])
                                For $i3 = 1 To $sl3
                                $fn3 = $fn2 & '-' & $i2
                                $xml3 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn3 & '-' & $i3
                                DirCreate($xml3)
                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                While 1
                                $rl = FileReadLine($fh)
                                If @error = -1 Then ExitLoop
                                FileCopy($rl, $xml3, 9)
                                                            WEnd
                                                            FileClose($fh)
                                $ywc = $ywc + 1
                                $sl4 = GUICtrlRead($s[4])
                                        For $i4 = 1 To $sl4
                                        $fn4 = $fn3 & '-' & $i3
                                        $xml4 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn4 & '-' & $i4
                                        DirCreate($xml4)
                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                While 1
                                        $rl = FileReadLine($fh)
                                        If @error = -1 Then ExitLoop
                                        FileCopy($rl, $xml4, 9)
                                        WEnd
                                        FileClose($fh)
                                                                                $ywc = $ywc + 1
                                        $sl5 = GUICtrlRead($s[5])
                                                For $i5 = 1 To $sl5
                                                $fn5 = $fn4 & '-' & $i4
                                                $xml5 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn5 & '-' & $i5
                                                DirCreate($xml5)
                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                While 1
                                                $rl = FileReadLine($fh)
                                                If @error = -1 Then ExitLoop
                                                FileCopy($rl, $xml5, 9)
                                                                                                WEnd
                                                FileClose($fh)
                                                                                                $ywc = $ywc + 1
                                                $sl6 = GUICtrlRead($s[6])
                                                        For $i6 = 1 To $sl6
                                                        $fn6 = $fn5 & '-' & $i5
                                                        $xml6 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn6 & '-' & $i6
                                                        DirCreate($xml6)
                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                While 1
                                                        $rl = FileReadLine($fh)
                                                        If @error = -1 Then ExitLoop
                                                        FileCopy($rl, $xml6, 9)
                                                        WEnd
                                                        FileClose($fh)
                                                                                                                $ywc = $ywc + 1
                                                        $sl7 = GUICtrlRead($s[7])
                                                                For $i7 = 1 To $sl7
                                                                $fn7 = $fn6 & '-' & $i6
                                                                $xml7 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn7 & '-' & $i7
                                                                DirCreate($xml7)
                                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                While 1
                                                                $rl = FileReadLine($fh)
                                                                If @error = -1 Then ExitLoop
                                                                FileCopy($rl, $xml7, 9)
                                                                                                                                WEnd
                                                                FileClose($fh)
                                                                                                                                $ywc = $ywc + 1
                                                                $sl8 = GUICtrlRead($s[8])
                                                                        For $i8 = 1 To $sl8
                                                                        $fn8 = $fn7 & '-' & $i7
                                                                        $xml8 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn8 & '-' & $i8
                                                                        DirCreate($xml8)
                                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                While 1
                                                                        $rl = FileReadLine($fh)
                                                                        If @error = -1 Then ExitLoop
                                                                        FileCopy($rl, $xml8, 9)
                                                                        WEnd
                                                                        FileClose($fh)
                                                                                                                                                $ywc = $ywc + 1
                                                                        $sl9 = GUICtrlRead($s[9])
                                                                                For $i9 = 1 To $sl9
                                                                                $fn9 = $fn8 & '-' & $i8
                                                                                $xml9 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn9 & '-' & $i9
                                                                                DirCreate($xml9)
                                                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                                While 1
                                                                                $rl = FileReadLine($fh)
                                                                                If @error = -1 Then ExitLoop
                                                                                FileCopy($rl, $xml9, 9)
                                                                                                                                                                WEnd
                                                                                FileClose($fh)
                                                                                                                                                                $ywc = $ywc + 1
                                                                                $sl10 = GUICtrlRead($s[10])
                                                                                        For $i10 = 1 To $sl10
                                                                                        $fn10 = $fn9 & '-' & $i9
                                                                                        $xml10 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn10 & '-' & $i10
                                                                                        DirCreate($xml10)
                                                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                                                While 1
                                                                                        $rl = FileReadLine($fh)
                                                                                        If @error = -1 Then ExitLoop
                                                                                        FileCopy($rl, $xml10, 9)
                                                                                                                                                                                WEnd
                                                                                        FileClose($fh)
                                                                                                                                                                            $ywc = $ywc + 1
                                                                                                                                                                                $sl11 = GUICtrlRead($s[11])
                                                                                                                                                                                         For $i11 = 1 To $sl11
                                                                                                 $fn11 = $fn10 & '-' & $i10
                                                                                                 $xml11 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\' & $fn11 & '-' & $i11
                                                                                                 DirCreate($xml11)
                                                                                                 $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                                                                 While 1
                                                                                                 $rl = FileReadLine($fh)
                                                                                                 If @error = -1 Then ExitLoop
                                                                                                 FileCopy($rl, $xml11, 9)
                                                                                                 WEnd
                                                                                                 FileClose($fh)
                                                                                                                                                                                                 $ywc = $ywc + 1
                                                                                                                                                                                                 $sl12 = GUICtrlRead($s[12])
                                                                                                                                                                                                                  For $i12 = 1 To $sl12
                                                                                                          $fn12 = $fn11 & '-' & $i11
                                                                                                          $xml12 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\'& $fn12 & '\' & $fn12 & '-' & $i12
                                                                                                          DirCreate($xml12)
                                                                                                          $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                                                                                  While 1
                                                                                                          $rl = FileReadLine($fh)
                                                                                                          If @error = -1 Then ExitLoop
                                                                                                          FileCopy($rl, $xml12, 9)
                                                                                                                                                                                                                  WEnd
                                                                                                          FileClose($fh)
                                                                                                                                                                                                                  $ywc = $ywc + 1
                                                                                                                                                                                                          $sl13 = GUICtrlRead($s[13])
                                                                                                                                                                                                                              For $i13 = 1 To $sl13
                                                                                                                  $fn13 = $fn12 & '-' & $i12
                                                                                                                  $xml13 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\'& $fn12 & '\'& $fn13 & '\' & $fn13 & '-' & $i13
                                                                                                                  DirCreate($xml13)
                                                                                                                  $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                                                                                                  While 1
                                                                                                                  $rl = FileReadLine($fh)
                                                                                                                  If @error = -1 Then ExitLoop
                                                                                                                  FileCopy($rl, $xml13, 9)
                                                                                                                  WEnd
                                                                                                                  FileClose($fh)
                                                                                                                                                                                                                                  $ywc = $ywc + 1
                                                                                                                                                                                                                  $sl14 = GUICtrlRead($s[14])
                                                                                                                                                                                                                                         For $i14 = 1 To $sl14
                                                                                                                         $fn14 = $fn13 & '-' & $i13
                                                                                                                         $xml14 = $gmlr&'\'&$fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\'  & $fn11 & '\'& $fn12 & '\'& $fn13 & '\'& $fn14 & '\' & $fn14 & '-' & $i14
                                                                                                                         DirCreate($xml14)
                                                                                                                         $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                                                                                                                                                 While 1
                                                                                                                                                                                                                                                 $rl = FileReadLine($fh)
                                                                                                                         If @error = -1 Then ExitLoop
                                                                                                                         FileCopy($rl, $xml14, 9)
                                                                                                                         WEnd
                                                                                                                         FileClose($fh)
                                                                                                                                                                                                                                                 $ywc = $ywc + 1
                                                                                                                                                                                                                         Next  
                                                                                                                                                                                                     Next
                                                                                                                                                                                      Next
                                                                                                                                                                           Next
                                                                                Next
                                                                        Next
                                                                Next
                                                        Next
                                                Next
                                        Next
                                Next
                        Next
                Next
                        Next
           FileDelete(@ScriptDir & "\1.txt")
EndFunc   ;==>scml
 楼主| 发表于 2009-8-13 09:38:43 | 显示全部楼层
我在147和148行之间尝试加入了
If $gmlr = '' Then 
                                FileClose($fh)
                                Else
不过好像不行,还是解决不了如果没有目标源文件就不自动创建文件夹的问题
发表于 2009-8-13 09:59:54 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#NoTrayIcon


$Form1 = GUICreate('Multi-Level Folder Creator', 387, 265, -1, -1)
Dim $n = 1, $l[15], $s[15], $fh
For $n = 1 To 14
        $l[$n] = GUICtrlCreateLabel("Lv" & $n, 12 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 18)
        $s[$n] = GUICtrlCreateInput("0", 45 + 70 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 17 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
        GUICtrlSetLimit(-1, 4)
Next
$yml = GUICtrlCreateInput("", 11, 85, 240, 23)
$Button = GUICtrlCreateButton("Create Folder / Copy File", 10, 160, 220, 25)
$Button1 = GUICtrlCreateButton("Remove All", 240, 160, 135, 25)
$Button2 = GUICtrlCreateButton("Source File Folder", 255, 84, 120, 26)
$Button3 = HotKeySet("{ESC}", "Terminate")
$gml = GUICtrlCreateInput("", 11, 120, 240, 23)
$Button5 = GUICtrlCreateButton("Target Folder", 255, 119, 120, 26)
$xs = GUICtrlCreateLabel("0/0        ", 175, 220, 300, 15)
GUICtrlSetColor(-1, 0xff0000)
$jdt = GUICtrlCreateProgress(10, 200, 365, 12, $PBS_SMOOTH)
$jdf = GUICtrlCreateProgress(10, 240, 365, 12, $PBS_SMOOTH)
GUISetState()

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

                Case $Button
                        GUICtrlSetData($jdt, 0)
                        GUICtrlSetState($Button, $GUI_ENABLE)
                        Dim $ywc = 0, $zs = 0, $sc = 1, $f, $h
                        jc()
                        AdlibEnable("jdt")
                        If GUICtrlRead($s[1]) = 0 Then
                                MsgBox(16, 'Error', 'Please set the number of folders')
                        Else
                                $f = MsgBox(1 + 48, 'Attention', 'You will create ' & $zs & ' folders.' & @CRLF & 'Do you wish to continue?')
                                Select
                                        Case $f = 1
                                                scml()
                                                Sleep(300)
                                                AdlibDisable()
                                                MsgBox(64, 'Finish', 'Created  ' & $zs & '  Folders! ')
                                        Case $f = 2
                                                ContinueLoop
                                EndSelect

                        EndIf
                        GUICtrlSetState($Button, $GUI_ENABLE)

                Case $Button1
                        $h = MsgBox(1 + 48, 'Attention', 'Are you sure you want to Delete all the folders ?')
                        Select
                                Case $h = 1
                                        Del()
                                        Sleep(300)
                                        MsgBox(64, 'Finish', 'You have deleted all the folders! ')
                                Case $h = 2
                                        ContinueLoop
                        EndSelect
                Case $Button2
                        $ywjj = FileSelectFolder("Choose The Folder", "", 4)
                        If @error Then ContinueLoop
                        GUICtrlSetData($yml, $ywjj)
                Case $Button3
                        Terminate()
                Case $Button5
                        $ywxx = FileSelectFolder("Choose The Folder", "", 4)
                        If @error Then ContinueLoop
                        GUICtrlSetData($gml, $ywxx)

        EndSwitch
WEnd

Func Del()
        Dim $num
        For $num = 1 To 1000
                $gmld = GUICtrlRead($gml)
                DirRemove($gmld & '\' & 'MP3-' & $num, 1)
        Next

EndFunc   ;==>Del

Func jc()
        For $i = 14 To 1 Step -1
                $sl = GUICtrlRead($s[$i])
                If $sl > 0 Then
                        For $i1 = 1 To $i
                                $sl1 = GUICtrlRead($s[$i1])
                                If $sl1 = 0 Then
                                        GUICtrlSetData($s[$i1], 1)
                                        $sl1 = 1
                                EndIf
                                $zs = $zs + ($sc * $sl1)
                                $sc = $sc * $sl1
                        Next
                        ExitLoop
                EndIf
        Next
EndFunc   ;==>jc

Func Terminate()
        Exit 0
EndFunc   ;==>Terminate
Func _filelist($searchdir, $hzm)
        $search = FileFindFirstFile($searchdir & "\*")
        If $search = -1 Then Return -1
        While 1
                $file = FileFindNextFile($search)
                If @error Then
                        FileClose($search)
                        Return
                ElseIf $file = "." Or $file = ".." Then
                        ContinueLoop
                ElseIf StringInStr(FileGetAttrib($searchdir & "" & $file), "D") Then
                        _filelist($searchdir & "" & $file, $hzm)
                        ContinueLoop
                EndIf
                If StringRight($file, 4) = $hzm Then
                        FileWriteLine($fh, $searchdir & "" & $file)
                EndIf
        WEnd
EndFunc   ;==>_filelist
Func jdt()
        GUICtrlSetData($jdt, $ywc / $zs * 100)
        GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc   ;==>jdt
Func scml()
        $ymlr = GUICtrlRead($yml)
        If $ymlr <> '' Then
                $fh = FileOpen(@ScriptDir & "\1.txt", 1)
                _filelist($ymlr, '.mp3')
                FileClose($fh)
        EndIf
        $gmlr = GUICtrlRead($gml)
        $sl1 = GUICtrlRead($s[1])
        If $gmlr = '' Then $gmlr = @ScriptDir
        For $i1 = 1 To $sl1
                $fn1 = 'MP3-'
                $xml1 = $gmlr & '\' & $fn1 & $i1
                DirCreate($xml1)
                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                If $fh <> -1 Then
                        While 1
                                $rl = FileReadLine($fh)
                                If @error = -1 Then ExitLoop
                                FileCopy($rl, $xml1, 9)
                        WEnd
                        FileClose($fh)
                EndIf
                $ywc = $ywc + 1
                $sl2 = GUICtrlRead($s[2])
                For $i2 = 1 To $sl2
                        $fn2 = $fn1 & $i1
                        $xml2 = $gmlr & '\' & $fn2 & '\' & $fn2 & '-' & $i2
                        DirCreate($xml2)
                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                        If $fh <> -1 Then
                                While 1
                                        $rl = FileReadLine($fh)
                                        If @error = -1 Then ExitLoop
                                        FileCopy($rl, $xml2, 9)
                                WEnd
                                FileClose($fh)
                        EndIf
                        $ywc = $ywc + 1
                        $sl3 = GUICtrlRead($s[3])
                        For $i3 = 1 To $sl3
                                $fn3 = $fn2 & '-' & $i2
                                $xml3 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn3 & '-' & $i3
                                DirCreate($xml3)
                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                If $fh <> -1 Then
                                        While 1
                                                $rl = FileReadLine($fh)
                                                If @error = -1 Then ExitLoop
                                                FileCopy($rl, $xml3, 9)
                                        WEnd
                                        FileClose($fh)
                                EndIf
                                $ywc = $ywc + 1
                                $sl4 = GUICtrlRead($s[4])
                                For $i4 = 1 To $sl4
                                        $fn4 = $fn3 & '-' & $i3
                                        $xml4 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn4 & '-' & $i4
                                        DirCreate($xml4)
                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                        If $fh <> -1 Then
                                                While 1
                                                        $rl = FileReadLine($fh)
                                                        If @error = -1 Then ExitLoop
                                                        FileCopy($rl, $xml4, 9)
                                                WEnd
                                                FileClose($fh)
                                        EndIf
                                        $ywc = $ywc + 1
                                        $sl5 = GUICtrlRead($s[5])
                                        For $i5 = 1 To $sl5
                                                $fn5 = $fn4 & '-' & $i4
                                                $xml5 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn5 & '-' & $i5
                                                DirCreate($xml5)
                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                If $fh <> -1 Then
                                                        While 1
                                                                $rl = FileReadLine($fh)
                                                                If @error = -1 Then ExitLoop
                                                                FileCopy($rl, $xml5, 9)
                                                        WEnd
                                                        FileClose($fh)
                                                EndIf
                                                $ywc = $ywc + 1
                                                $sl6 = GUICtrlRead($s[6])
                                                For $i6 = 1 To $sl6
                                                        $fn6 = $fn5 & '-' & $i5
                                                        $xml6 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn6 & '-' & $i6
                                                        DirCreate($xml6)
                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                        If $fh <> -1 Then
                                                                While 1
                                                                        $rl = FileReadLine($fh)
                                                                        If @error = -1 Then ExitLoop
                                                                        FileCopy($rl, $xml6, 9)
                                                                WEnd
                                                                FileClose($fh)
                                                        EndIf
                                                        $ywc = $ywc + 1
                                                        $sl7 = GUICtrlRead($s[7])
                                                        For $i7 = 1 To $sl7
                                                                $fn7 = $fn6 & '-' & $i6
                                                                $xml7 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn7 & '-' & $i7
                                                                DirCreate($xml7)
                                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                If $fh <> -1 Then
                                                                        While 1
                                                                                $rl = FileReadLine($fh)
                                                                                If @error = -1 Then ExitLoop
                                                                                FileCopy($rl, $xml7, 9)
                                                                        WEnd
                                                                        FileClose($fh)
                                                                EndIf
                                                                $ywc = $ywc + 1
                                                                $sl8 = GUICtrlRead($s[8])
                                                                For $i8 = 1 To $sl8
                                                                        $fn8 = $fn7 & '-' & $i7
                                                                        $xml8 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn8 & '-' & $i8
                                                                        DirCreate($xml8)
                                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                        If $fh <> -1 Then
                                                                                While 1
                                                                                        $rl = FileReadLine($fh)
                                                                                        If @error = -1 Then ExitLoop
                                                                                        FileCopy($rl, $xml8, 9)
                                                                                WEnd
                                                                                FileClose($fh)
                                                                        EndIf
                                                                        $ywc = $ywc + 1
                                                                        $sl9 = GUICtrlRead($s[9])
                                                                        For $i9 = 1 To $sl9
                                                                                $fn9 = $fn8 & '-' & $i8
                                                                                $xml9 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn9 & '-' & $i9
                                                                                DirCreate($xml9)
                                                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                If $fh <> -1 Then
                                                                                        While 1
                                                                                                $rl = FileReadLine($fh)
                                                                                                If @error = -1 Then ExitLoop
                                                                                                FileCopy($rl, $xml9, 9)
                                                                                        WEnd
                                                                                        FileClose($fh)
                                                                                EndIf
                                                                                $ywc = $ywc + 1
                                                                                $sl10 = GUICtrlRead($s[10])
                                                                                For $i10 = 1 To $sl10
                                                                                        $fn10 = $fn9 & '-' & $i9
                                                                                        $xml10 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn10 & '-' & $i10
                                                                                        DirCreate($xml10)
                                                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                        If $fh <> -1 Then
                                                                                                While 1
                                                                                                        $rl = FileReadLine($fh)
                                                                                                        If @error = -1 Then ExitLoop
                                                                                                        FileCopy($rl, $xml10, 9)
                                                                                                WEnd
                                                                                                FileClose($fh)
                                                                                        EndIf
                                                                                        $ywc = $ywc + 1
                                                                                        $sl11 = GUICtrlRead($s[11])
                                                                                        For $i11 = 1 To $sl11
                                                                                                $fn11 = $fn10 & '-' & $i10
                                                                                                $xml11 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn11 & '\' & $fn11 & '-' & $i11
                                                                                                DirCreate($xml11)
                                                                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                If $fh <> -1 Then
                                                                                                        While 1
                                                                                                                $rl = FileReadLine($fh)
                                                                                                                If @error = -1 Then ExitLoop
                                                                                                                FileCopy($rl, $xml11, 9)
                                                                                                        WEnd
                                                                                                        FileClose($fh)
                                                                                                EndIf
                                                                                                $ywc = $ywc + 1
                                                                                                $sl12 = GUICtrlRead($s[12])
                                                                                                For $i12 = 1 To $sl12
                                                                                                        $fn12 = $fn11 & '-' & $i11
                                                                                                        $xml12 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn11 & '\' & $fn12 & '\' & $fn12 & '-' & $i12
                                                                                                        DirCreate($xml12)
                                                                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                        If $fh <> -1 Then
                                                                                                                While 1
                                                                                                                        $rl = FileReadLine($fh)
                                                                                                                        If @error = -1 Then ExitLoop
                                                                                                                        FileCopy($rl, $xml12, 9)
                                                                                                                WEnd
                                                                                                                FileClose($fh)
                                                                                                        EndIf
                                                                                                        $ywc = $ywc + 1
                                                                                                        $sl13 = GUICtrlRead($s[13])
                                                                                                        For $i13 = 1 To $sl13
                                                                                                                $fn13 = $fn12 & '-' & $i12
                                                                                                                $xml13 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn11 & '\' & $fn12 & '\' & $fn13 & '\' & $fn13 & '-' & $i13
                                                                                                                DirCreate($xml13)
                                                                                                                $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                If $fh <> -1 Then
                                                                                                                        While 1
                                                                                                                                $rl = FileReadLine($fh)
                                                                                                                                If @error = -1 Then ExitLoop
                                                                                                                                FileCopy($rl, $xml13, 9)
                                                                                                                        WEnd
                                                                                                                        FileClose($fh)
                                                                                                                EndIf
                                                                                                                $ywc = $ywc + 1
                                                                                                                $sl14 = GUICtrlRead($s[14])
                                                                                                                For $i14 = 1 To $sl14
                                                                                                                        $fn14 = $fn13 & '-' & $i13
                                                                                                                        $xml14 = $gmlr & '\' & $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn11 & '\' & $fn12 & '\' & $fn13 & '\' & $fn14 & '\' & $fn14 & '-' & $i14
                                                                                                                        DirCreate($xml14)
                                                                                                                        $fh = FileOpen(@ScriptDir & "\1.txt", 0)
                                                                                                                        If $fh <> -1 Then
                                                                                                                                While 1
                                                                                                                                        $rl = FileReadLine($fh)
                                                                                                                                        If @error = -1 Then ExitLoop
                                                                                                                                        FileCopy($rl, $xml14, 9)
                                                                                                                                WEnd
                                                                                                                                FileClose($fh)
                                                                                                                        EndIf
                                                                                                                        $ywc = $ywc + 1
                                                                                                                Next
                                                                                                        Next
                                                                                                Next
                                                                                        Next
                                                                                Next
                                                                        Next
                                                                Next
                                                        Next
                                                Next
                                        Next
                                Next
                        Next
                Next
        Next
        FileDelete(@ScriptDir & "\1.txt")
EndFunc   ;==>scml
 楼主| 发表于 2009-8-13 20:01:40 | 显示全部楼层
89# afan


果然这样,谢谢你afan!!我现在还不大明白的就是那个进度条了,我想在删除的时候也做一个进度条出来,我了看你的应该是计算总文件,然后另外一个是依次递增的这样。于是我就打算直接吧总文件直接读取过来,然后再做一个从0到总文件数量依次递增的进度条,这样也就可以达到表示删除的效果吧??但是我做了出来却不成功。
 Case $Button
                        GUICtrlSetData($jdt, 0)
                        GUICtrlSetState($Button, $GUI_ENABLE)
                        Dim $ywc = 0, $zs = 0, $sc = 1, $f, $h
                        jc()
                        AdlibEnable("jdt")
                        If GUICtrlRead($s[1]) = 0 Then
                                MsgBox(16, 'Error', 'Please set the number of folders')
                        Else
                                $f = MsgBox(1 + 48, 'Attention', 'You will create ' & $zs & ' folders.' & @CRLF & 'Do you wish to continue?')
                                Select
                                        Case $f = 1
                                                scml()
                                                Sleep(300)
                                                AdlibDisable()
                                                MsgBox(64, 'Finish', 'Created  ' & $zs & '  Folders! ')
                                        Case $f = 2
                                                ContinueLoop
                                EndSelect

                        EndIf
                        GUICtrlSetState($Button, $GUI_ENABLE)

                Case $Button1
                        $ywcc = GUICtrlRead($ywc)
                                $zss = GUICtrlRead($zs)
                                                GUICtrlSetData($jdf, 0)
                        GUICtrlSetState($Button1, $GUI_ENABLE)
                                                AdlibEnable("jdf")
                                                $h = MsgBox(1 + 48, 'Attention', 'Are you sure you want to Delete all the folders ?')
                        Select
                                                        Case $h = 1
                                                                        Del()
                                        Sleep(300)
                                                                                AdlibDisable()
                                        MsgBox(64, 'Finish', 'You have deleted all the folders! ')
                                Case $h = 2
                                        ContinueLoop
                        EndSelect
...........
...........
...........
Func jdf()
                GUICtrlSetData($jdf, $ywcc / $zss * 100)
EndFunc
然后我打算添加一个$ywcc = $ywcc - 1在中间,却怎么都弄不对。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 16:19 , Processed in 0.085990 second(s), 15 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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