#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