Copy (Robocopy) or Link (Mklink) Interface

Post your working scripts, libraries and tools for AHK v1.1 and older
Resease
Posts: 1
Joined: 14 Nov 2017, 09:17

Copy (Robocopy) or Link (Mklink) Interface

14 Nov 2017, 10:22

You can see both interface and the actions performed on CMD by the buttons below:
Image


- Copy a folder and Delete the original one: robocopy "%Original%" "%NewFolder%" /E /R:3 /W:15 /V /MT /MOVE /TEE /ETA /LOG:"%NewFolder%\Log_Copied_files.txt"
- Copy a folder and Keep the original one: robocopy "%Original%" "%NewFolder%" /E /R:3 /W:15 /V /MT /TEE /ETA /LOG:"%NewFolder%\Log_Copied_files.txt"
- Create a Link to a folder : robocopy "%Original%" "%NewFolder%" /E /R:3 /W:15 /V /MT /MOVE /TEE /ETA /LOG:"%NewFolder%\Log_Copied_files.txt" and mklink /d "%Original%" "%NewFolder%.

To add the folders you can click at their buttons or copy and paste the paths.

So, you can use it to copy large files (Backups/Move folders) or link folders (useful to move folders from installed programs avoiding problems). Google these commands to see the full description, you can also change their settings in the script just look for the variable "command1".

To run the script easy and fast you can compile it to .exe and go to:
My computer -> Properties ->Advanced settings -> Advanced -> Environment variables -> System variables -> Path -> Edit -> New and put the directory from the .exe file. Now, you can just press Win+R and type the name of the .exe.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance Force

gui, font, s13, Arial
Gui, Color,  C0C0C0 
Gui, Add, Button, xm y+20 w100 gBr1,OLD folder:
Gui, Add, Edit, x+20  w1000 vOriginal, %Original%
Gui, Add, Button, xm y+50 w105 gBr2,NEW folder:
Gui, Add, Edit, x+20  w1000 vNewFolder, %NewFolder%
Gui, Add, Button, x400 y+30 w320 gOp1, Copy a folder and Delete the original one
Gui, Add, Button,  y+50 w320 gOp2, Copy a folder and Keep the original one
Gui, Add, Button,  y+50 w320 gOp3, Create a Link to a folder
Gui, Show, , Copy or Link folders
return

GuiClose:
Gui, destroy 
ExitApp


Br1:
Gui, Submit, NoHide
FileSelectFolder,Original, , , Select your OLD folder: (THIS FOLDER CONTAINS THE FILES TO BE COPYED, IT WILL BE KEPT, DELETED OR LINKED.)
GuiControl, ,Original, %Original%
return

Br2:
Gui, Submit, NoHide
FileSelectFolder,NewFolder, , , Select your NEW folder:   (THIS FOLDER WILL HAVE THE NEW FILES OR THE ORIGINAL ONES FROM LINKING.)
GuiControl, ,NewFolder, %NewFolder%
return

Op1:
{
Gui, Submit,NoHide

if (Original) && (NewFolder)
{
MsgBox,1,Confirmation !, COPY a folder and DELETE the original one. `n`n From: %Original% `n`n To: %NewFolder% 
ifMsgBox, OK
{
command1 = robocopy "%Original%" "%NewFolder%" /E /R:3 /W:15 /V /MT /MOVE /TEE /ETA /LOG:"%NewFolder%\Log_Copied_files.txt"
runwait, *RunAs %comspec% /c %command1%, , Min

MsgBox,1, Process Completed !!, Open Logs ? 
IfMsgBox, Ok
{
Run,"%NewFolder%\Log_Copied_files.txt"
ExitApp
}
else  
ExitApp

}
else
return
}
else
{
MsgBox, Please, select both folders
return
}

}

Op2:
{
Gui, Submit, NoHide

if (Original) && (NewFolder)
{
MsgBox,1,Confirmation !, COPY a folder and KEEP the original one. `n`n From: %Original% `n`n To: %NewFolder% 
ifMsgBox, OK
{
command1 = robocopy "%Original%" "%NewFolder%" /E /R:3 /W:15 /V /MT /TEE /ETA /LOG:"%NewFolder%\Log_Copied_files.txt"
runwait, *RunAs %comspec% /c %command1%, , Min

MsgBox,1, Process Completed !!, Open Logs ? 
IfMsgBox, Ok
{
Run,"%NewFolder%\Log_Copied_files.txt"
ExitApp
}
else  
ExitApp

}
else
return
}
else
{
MsgBox, Please, select both folders
return
}

}

Op3:
{
Gui, Submit, NoHide

if (Original) && (NewFolder)
{
MsgBox,1,Confirmation !, Create a LINK to a folder. `n`n From: %Original% `n`n To: %NewFolder% 
ifMsgBox, OK
{
command1 = robocopy "%Original%" "%NewFolder%" /E /R:3 /W:15 /V /MT /MOVE /TEE /ETA /LOG:"%NewFolder%\Log_Copied_files.txt"
command2 = mklink /d "%Original%" "%NewFolder%
runwait, *RunAs %comspec% /c %command1% & %command2%, , Min

MsgBox,1, Process Completed !!, Open Logs ? 
IfMsgBox, Ok
{
Run,"%NewFolder%\Log_Copied_files.txt"
ExitApp
}
else  
ExitApp

}
else
return
}
else
{
MsgBox, Please, select both folders
return
}

}

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 47 guests