-
Notifications
You must be signed in to change notification settings - Fork 71
/
ExplorerGrouping.ahk
168 lines (145 loc) · 3.94 KB
/
ExplorerGrouping.ahk
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
; ===== Autohotkey script for Windows Explorer =====
; Sets two hotkeys:
; Ctrl+G - Moves the selected files to a GroupNN folder
; Ctrl+Shift+G - Moves the files from selected folders to an upper level,
; then removes those directories
;
; For the script to function properly, please go to Explorer's
; Tools - Folder Options - View menu and ensure that
; 'Display the full path in the address bar' is on
; and 'Hide extensions for known file types' is off
;
; (c)2008 by YasonBy
; Feel free to modify :)
; ===== Autohotkey c????? ??? ?????????? =====
; ????????????? ??? ??????? ???????:
; Ctrl+G - ????????? ?????????? ????? ? ????? ???? GroupNN
; Ctrl+Shift+G - ????????? ????? ?? ?????????? ????? ??????? ????,
; ????? ??????? ??? ?????????? ?????
;
; ??? ?????????? ?????? ????? ????? ? Tools - Folder Options - View
; ? ???????? Display the full path in the address bar
; ? ????????? Hide extensions for known file types
;
; (c)2008 by YasonBy
; ???????? ????????, ??????? ??? ?????? :)
#NoEnv
SendMode Input
; Defines a new group name and returns full path to it
; ?????????? ??? ????? ?????? ? ?????????? ?????? ???? ? ???
GetNewGroupName(dir) {
loop 100 {
groupPath = %dir%\Group%A_Index%
If !InStr(FileExist(groupPath),"D")
break
}
Return, groupPath
}
;Sets the input focus to the file list
; ????????????? ????? ????? ?? ?????? ??????
FocusFolderView() {
ControlFocus, SysListView321
}
; Returns the current path from explorer's address bar
; ?????????? ???? ?? ???????? ?????? ??????????
GetExplorerDirectory() {
ControlGetText, path, Edit1 ;getting current directory
return %path%
}
; Navigates Explorer into the specified directory
; ????????? ????????? ? ????????? ?????
SetExplorerDirectory(dir) {
ControlSetText, Edit1, %dir% ; change directory
ControlSend, Edit1, {ENTER} ; press Enter
FocusFolderView()
}
; Moves the 'source' file or directory into the 'dest' directory
; ?????????? ???? ??? ????? source ? ????? dest
MoveFileOrDir(source, dest) {
attributes := FileExist(source)
IfInString, attributes, D
{
FileMoveDir, %source%, %dest%, 1
}
else
{
FileMove, %source%, %dest%
}
}
; Moves the selected files to a GroupNN folder
; ????????? ?????????? ????? ? ????? ???? GroupNN
GroupSelectedFiles() {
currentDir := GetExplorerDirectory()
ClipSaved := ClipboardAll
clipboard =
FocusFolderView()
Send, {CTRL DOWN}c{CTRL UP}
ClipWait,2
If !clipboard,
return ; nothing selected - nothing to do
newGroupDir := GetNewGroupName(currentDir)
FileCreateDir, %newGroupDir%
Loop, parse, clipboard, `n, `r
{
fileName = %A_LoopField%
MoveFileOrDir(fileName, newGroupDir)
}
Clipboard := ClipSaved
ClipSaved =
; Uncomment this, if you want to move into the created group
; ?????????????????, ???? ????? ?????????? ? ?????? ??? ????????? ??????
; SetExplorerDirectory(newGroupDir)
Send, {F5}
}
; Moves the files from selected folders to an upper level, then removes those directories
; ????????? ????? ?? ?????????? ????? ??????? ????, ????? ??????? ??? ?????????? ?????
UngroupSelectedFiles() {
currentDir := GetExplorerDirectory()
ClipSaved := ClipboardAll
clipboard =
FocusFolderView()
Send, {CTRL DOWN}c{CTRL UP}
ClipWait,1
Loop, parse, clipboard, `n, `r
{
groupPath = %A_LoopField%
attributes := FileExist(groupPath)
IfInString, attributes, D
{
Loop, %groupPath%\*.*,1,0
{
MoveFileOrDir(A_LoopFileFullPath, currentDir)
}
FileRemoveDir, %groupPath%, 0 ;non-recursive
}
}
Clipboard := ClipSaved
ClipSaved =
Send, {F5}
}
/*
; ??????? ??????? ?????? ??? Windows Explorer'? (WinXP x64)
#IfWinActive, ahk_class ExploreWClass
^g::
KeyWait Control
GroupSelectedFiles()
return
^+g::
KeyWait Control
KeyWait Shift
UngroupSelectedFiles()
return
#IfWinActive
; ??????? ??????? ?????? ??? Windows Explorer'? (WinXP)
#IfWinActive, ahk_class CabinetWClass
^g::
KeyWait Control
GroupSelectedFiles()
return
^+g::
KeyWait Control
KeyWait Shift
UngroupSelectedFiles()
return
#IfWinActive
*/