Last active
April 3, 2022 18:48
-
-
Save stefan-matic/b5264dfd03de6e2ca10f999fc6a209a6 to your computer and use it in GitHub Desktop.
Allow moving files to specified folders in the code based on the key pressed. Edit lines 6-10 for key binds and 16-25 for folder paths. F1 suspends the hotkeys so you can use the keyboard normally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GroupAdd, WinGroupFolder, ahk_class CabinetWClass | |
GroupAdd, WinGroupFolder, ahk_class ExploreWClass | |
#IfWinActive ahk_group WinGroupFolder | |
F1::Suspend | |
q:: | |
t:: | |
f:: | |
g:: | |
d:: | |
WinGet, hWnd, ID, A | |
WinGetClass, vWinClass, % "ahk_id " hWnd | |
if vWinClass not in CabinetWClass,ExploreWClass | |
return | |
if A_ThisHotkey contains q | |
vDir2 = X:\Folder\1 | |
if A_ThisHotkey contains t | |
vDir2 = X:\Folder\2 | |
if A_ThisHotkey contains f | |
vDir2 = X:\Folder\3 | |
if A_ThisHotkey contains g | |
vDir2 = X:\Folder\6 | |
if A_ThisHotkey contains d | |
vDir2 = X:\Folder\5 | |
if !FileExist(vDir2) | |
FileCreateDir, % vDir2 | |
vList := "" | |
VarSetCapacity(vList, 1000000*2) | |
for oWin in ComObjCreate("Shell.Application").Windows | |
if (oWin.HWND = hWnd) | |
{ | |
for oItem in oWin.Document.SelectedItems | |
vList .= oItem.path "`n" | |
oItem := "" | |
break | |
} | |
oWin := "" | |
Loop, Parse, vList, `n | |
{ | |
vPath1 := A_LoopField | |
if (vPath1 = "") | |
continue | |
SplitPath, vPath1, vName1, vDir1, vExt1, vNameNoExt1, vDrive1 | |
Loop | |
{ | |
if (A_Index = 1) | |
vPath2 := vDir2 "\" vName1 | |
else | |
vPath2 := vDir2 "\" vNameNoExt1 " (" (A_Index-1) ")." vExt1 | |
if !FileExist(vPath2) | |
break | |
} | |
;MsgBox, % vPath1 "`r`n`r`n" vPath2 | |
FileMove, % vPath1, % vPath2 | |
} | |
;MsgBox % "done" | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment