1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| ; --------------------------------------------Main--------------------------------------------------
Gui, -SysMenu
Gui, Font, s12 Bold, Calibri
Gui, Add, Text, w300 +Center, % "Define a folder to work with!"
Gui, Add, Edit, w300 +Center ReadOnly cRed vLocation
Gui, Add, Button, w300, % "Define"
Gui, Add, Text, w300 0x10
Gui, Add, Button, w300, % "Apply"
Gui, Show,, Re-Organise
Return
ButtonDefine:
FileSelectFolder, Selected,, 3, % "Select a folder"
If (Selected != "")
GuiControl,, Location, % Selected
Return
~^a::
ButtonApply:
Gui, Submit, NoHide
If (Location != "") && FolderExist(Location)
{
DoTheWork(Location, Log)
Msgbox, 64, % "Info", % "Everything must be done by now!"
}
Else
Msgbox, 64, % "Info", % "Define a folder to work with!"
Return
Esc::
GuiEscape:
GuiClose:
ExitApp
; ------------------------------------------Functions-----------------------------------------------
FolderExist(Path)
{
If !InStr(FileExist(Path), "D")
Return 0
Else
Return 1
}
DoTheWork(Path, Output)
{
NewLocation := Path "_New"
If !FolderExist(NewLocation)
FileCreateDir, % NewLocation
Loop, Files, % Path "\*", D
{
Level_1 := A_LoopFileFullPath, Foldername := A_LoopFileName
Loop, Files, % Level_1 "\*", D F
{
If FolderExist(A_LoopFileFullPath)
{
If !FolderExist(NewLocation "\" A_LoopFileName)
FileCreateDir, % NewLocation "\" A_LoopFileName
If !FolderExist(NewLocation "\" A_LoopFileName "\" Foldername)
FileCreateDir, % NewLocation "\" A_LoopFileName "\" Foldername
FileCopyDir, % A_LoopFileFullPath, % NewLocation "\" A_LoopFileName "\" Foldername, 1
}
Else
{
FileName := SubStr(A_LoopFileName, 1, StrLen(A_LoopFileName) - StrLen(A_LoopFileExt) - 1)
If !FolderExist(NewLocation "\" FileName)
FileCreateDir, % NewLocation "\" FileName
If !FolderExist(NewLocation "\" FileName "\" Foldername)
FileCreateDir, % NewLocation "\" FileName "\" Foldername
FileCopy, % A_LoopFileFullPath, % NewLocation "\" FileName "\" Foldername, 1
}
}
}
} |
Partager