Moving on...
A list of extensions tied to sub directory values saved as suffix.txt
looks like
Quote:
DXF * DWG * DWS = \Drawings
...
...
else =
and company list as prefix.txt, looks like
Mon = C:\Documents and Settings\Just Me\Desktop\Company Directory\Money Making Industries
This modified version of the script recognizes the prefix for directory followed by suffix for further organization
Code:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#NoTrayIcon
#SingleInstance
RegRead, regpath , HKEY_CLASSES_ROOT, *\shell\Organize\Command,
regpathV = AutoHotkey.exe "%A_ScriptFullPath%" "`%1"
IfNotInString, regpath, %regpathV%
{
MsgBox,
(
Registryentry changed.
This is the new path:
%regpathV%
)
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, *\shell\Organize\Command,, AutoHotkey.exe "%A_ScriptFullPath%" "`%1"
RegWrite, REG_SZ, HKEY_CLASSES_ROOT, AllFilesystemObjects\shell\Organize\Command,, AutoHotkey.exe "%A_ScriptFullPath%" "`%1"
}
if(%0% > 0)
{
fullPath = %1%
}else
{
ExitApp
}
revfullPath := revtxt(fullPath)
StringGetPos, cut, revfullPath, \
StringLeft, revfullPath, revfullPath, %cut%
revfullPath := revtxt(revfullPath)
StringGetPos, pos, revfullPath, .
if pos >= 0
{
organizeThis(fullPath)
}else
{
FileList =
Loop, %fullPath%\*.*
FileList = %FileList%%A_LoopFileName%`n
Sort, FileList, R
Loop, parse, FileList, `n
{
if A_LoopField =
continue
organizeThis(fullPath "\" A_LoopField)
}
}
revtxt(inVar)
{
VarSetCapacity(out, n:=StrLen(inVar))
Loop %n%
out .= SubStr(inVar, n--, 1)
return out
}
organizeThis(fullPath)
{
revfullPath := revtxt(fullPath)
StringGetPos, cut, revfullPath, \
StringLeft, revfullPath, revfullPath, %cut%
revfullPath := revtxt(revfullPath)
StringGetPos, pos, revfullPath, .
StringLeft, path_suffix, revfullPath, %pos%
Loop, read, prefix.txt
{
StringSplit, zeile, A_LoopReadLine, = , %A_Space%%A_Tab%
StringSplit, Array, zeile1, * , %A_Space%%A_Tab%
Loop, %Array0%
{
suffix := Array%a_index%
path_suffix := path_suffix
if suffix = %path_suffix%
{
clipboard = %zeile2%
}
}
}
}
reversefullPath := revtxt(fullPath)
StringGetPos, pos, reversefullPath, .
if pos >= 0
{
organizeThat(fullPath)
}else
{
FileList =
Loop, %fullPath%\*.*
FileList = %FileList%%A_LoopFileName%`n
Sort, FileList, R
Loop, parse, FileList, `n
{
if A_LoopField =
continue
organizeThis(fullPath "\" A_LoopField)
}
}
ExitApp
organizeThat(fullPath)
{
reversefullPath := revtxt(fullPath)
StringGetPos, pos, reversefullPath, .
StringLeft, reversefullPath, reversefullPath, %pos%
path_suffix := revtxt(reversefullPath)
Loop, read, suffix.txt
{
StringSplit, zeile, A_LoopReadLine, = , %A_Space%%A_Tab%
StringSplit, Array, zeile1, * , %A_Space%%A_Tab%
Loop, %Array0%
{
suffix := Array%a_index%
path_suffix := path_suffix
If (suffix = path_suffix OR suffix = "else")
{
destination = %clipboard%%zeile2%
IfNotExist, %destination%
FileCreateDir, %destination%
FileMove, %fullPath%, %destination%
}
}
}
}
so when organizing a file mon.PurchaseOrder.pdf that file is moved to Desktop\Company Directory\Money Making Industries\Documents
also any other file type not listed is moved to the parent directory; so mon.unsorted.mess would be moved to Desktop\Company Directory\Money Making Industries