AutoHotkey Community

It is currently May 27th, 2012, 12:34 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: help
PostPosted: January 17th, 2012, 3:42 pm 
Offline

Joined: December 6th, 2010, 3:17 pm
Posts: 17
Location: pp
first. good work here.
by the looks of it this script is very close to what i need to make.


Last edited by Er0ck on January 17th, 2012, 8:14 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 7:46 pm 
Offline

Joined: December 6th, 2010, 3:17 pm
Posts: 17
Location: pp
so i want prefixes to be a part of the organize option as well. as in TMP.filesname.ext will goto blabla\Temporary Jan\Extension type files\filesname.ext
as a start i want to get the script to look at initial characters. i tried removing revtxt() and using a filler string but that didnt move the file. also tried this simple change, not working. only works as intended

from

Code:
revtxt(inVar)
{
    VarSetCapacity(out, n:=StrLen(inVar))
    Loop %n%
        out .= SubStr(inVar, n--, 1)
    return out
}


into

Code:
revtxt(inVar)
{
    return inVar
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 17th, 2012, 8:13 pm 
Offline

Joined: December 6th, 2010, 3:17 pm
Posts: 17
Location: pp
ok i know what was wrong. this modified script goes by only prefix.
i can finish it from here
Code:


#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#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% ; <- the error was here
}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 =  ; Initialize to be blank.
  Loop, %fullPath%\*.*
      FileList = %FileList%%A_LoopFileName%`n
  Sort, FileList, R  ; The R option sorts in reverse order. See Sort for other options.
  Loop, parse, FileList, `n
  {
      if A_LoopField =  ; Ignore the blank item at the end of the list.
          continue
      organizeThis(fullPath "\" A_LoopField)
  }
}
ExitApp


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, ini.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%
      {
        FileMove, %fullPath%, %zeile2%
      }
    }
  }
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2012, 7:17 pm 
Offline

Joined: December 6th, 2010, 3:17 pm
Posts: 17
Location: pp
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, maul.esel and 8 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group