#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#NoTrayIcon
$Form1 = GUICreate('多层文件夹生成工具', 385, 150)
Dim $n = 1, $l[11], $s[11]
For $n = 1 To 10
$l[$n] = GUICtrlCreateLabel("第" & $n & "层", 12 + 74 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 23 + 20 * (Int(($n - 1) / 5)), 37, 16)
$s[$n] = GUICtrlCreateInput("0", 46 + 74 * ($n - (Int(($n - 1) / 5)) * 5 - 1), 20 + 20 * (Int(($n - 1) / 5)), 30, 16, $ES_NUMBER)
GUICtrlSetLimit(-1, 4)
Next
$yml = GUICtrlCreateInput("", 10, 70, 295, 20)
$Button2 = GUICtrlCreateButton("源文件夹", 306, 69, 70, 22)
$Button = GUICtrlCreateButton("生成文件夹(&G)", 80, 95, 190, 25)
$xs = GUICtrlCreateLabel("0/0", 290, 108, 80, 15)
GUICtrlSetColor(-1, 0x0000FF)
$jdt = GUICtrlCreateProgress(10, 125, 365, 12)
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
exit
Case $Button
GUICtrlSetData($jdt, 0)
GUICtrlSetState($Button, $GUI_DISABLE)
Dim $ywc = 0, $zs = 0, $sc = 1
jc()
AdlibEnable("jdt")
If GUICtrlRead($s[1]) = 0 then
msgbox(48, '问题', '未设置文件夹数量? 请返回设置。 ')
Else
scml()
sleep(250)
AdlibDisable()
msgbox(64, '完成', '创建 ' & $zs & ' 个文件夹完成! ')
endif
GUICtrlSetState($Button, $GUI_ENABLE)
Case $Button2
$ywjj = FileSelectFolder("选择文件夹", "", 4)
If @error Then ContinueLoop
GUICtrlSetData($yml, $ywjj)
EndSwitch
WEnd
Func jc()
For $i = 10 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 scml()
$ymlr = GUICtrlRead($yml)
$sl1 = GUICtrlRead($s[1])
For $i1 = 1 To $sl1
$fn1 = 'F'
$xml1 = $fn1 & $i1
DirCreate($xml1)
if $ymlr <> '' then DirCopy($ymlr, $xml1, 1)
$ywc = $ywc + 1
$sl2 = GUICtrlRead($s[2])
For $i2 = 1 To $sl2
$fn2 = $fn1 & $i1
$xml2 = $fn2 & '\' & $fn2 & '-' & $i2
DirCreate($xml2)
if $ymlr <> '' then DirCopy($ymlr, $xml2, 1)
$ywc = $ywc + 1
$sl3 = GUICtrlRead($s[3])
For $i3 = 1 To $sl3
$fn3 = $fn2 & '-' & $i2
$xml3 = $fn2 & '\' & $fn3 & '\' & $fn3 & '-' & $i3
DirCreate($xml3)
if $ymlr <> '' then DirCopy($ymlr, $xml3, 1)
$ywc = $ywc + 1
$sl4 = GUICtrlRead($s[4])
For $i4 = 1 To $sl4
$fn4 = $fn3 & '-' & $i3
$xml4 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn4 & '-' & $i4
DirCreate($xml4)
if $ymlr <> '' then DirCopy($ymlr, $xml4, 1)
$ywc = $ywc + 1
$sl5 = GUICtrlRead($s[5])
For $i5 = 1 To $sl5
$fn5 = $fn4 & '-' & $i4
$xml5 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn5 & '-' & $i5
DirCreate($xml5)
if $ymlr <> '' then DirCopy($ymlr, $xml5, 1)
$ywc = $ywc + 1
$sl6 = GUICtrlRead($s[6])
For $i6 = 1 To $sl6
$fn6 = $fn5 & '-' & $i5
$xml6 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn6 & '-' & $i6
DirCreate($xml6)
if $ymlr <> '' then DirCopy($ymlr, $xml6, 1)
$ywc = $ywc + 1
$sl7 = GUICtrlRead($s[7])
For $i7 = 1 To $sl7
$fn7 = $fn6 & '-' & $i6
$xml7 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn7 & '-' & $i7
DirCreate($xml7)
if $ymlr <> '' then DirCopy($ymlr, $xml7, 1)
$ywc = $ywc + 1
$sl8 = GUICtrlRead($s[8])
For $i8 = 1 To $sl8
$fn8 = $fn7 & '-' & $i7
$xml8 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn8 & '-' & $i8
DirCreate($xml8)
if $ymlr <> '' then DirCopy($ymlr, $xml8, 1)
$ywc = $ywc + 1
$sl9 = GUICtrlRead($s[9])
For $i9 = 1 To $sl9
$fn9 = $fn8 & '-' & $i8
$xml9 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn9 & '-' & $i9
DirCreate($xml9)
if $ymlr <> '' then DirCopy($ymlr, $xml9, 1)
$ywc = $ywc + 1
$sl10 = GUICtrlRead($s[10])
For $i10 = 1 To $sl10
$fn10 = $fn9 & '-' & $i9
$xml10 = $fn2 & '\' & $fn3 & '\' & $fn4 & '\' & $fn5 & '\' & $fn6 & '\' & $fn7 & '\' & $fn8 & '\' & $fn9 & '\' & $fn10 & '\' & $fn10 & '-' & $i10
DirCreate($xml10)
if $ymlr <> '' then DirCopy($ymlr, $xml10, 1)
$ywc = $ywc + 1
Next
Next
Next
Next
Next
Next
Next
Next
Next
Next
Endfunc ;==>scml
Func jdt()
GUICtrlSetData($jdt, $ywc / $zs * 100)
GUICtrlSetData($xs, $ywc & '/' & $zs)
EndFunc ;==>jdt