Page 1 of 1

LiberKey offline files sorter

Posted: Mon Nov 22, 2010 10:42 pm
by Fangbeast
I use a wonderful little portable menuing system called LiberKey and recently learned how to get it to store the updates locally for me to give to other people, rather than just updating LiberKey and then deleting them.

That left me with the problem of keeping them sorted in the order the LiberKey installs them (Category, subcategory) as my friends didn't want ALL the updates.

So I created a text catalogue file of all the updates available on the LiberKey site with Category/Subcategory/Filebasename and made this sorter.

Now when I have a few hundred megabytes of offline LiberKey updates, I just run this sorter.

Code: Select all

;==================================================================================================
; 
;==================================================================================================

; Window Constants

Enumeration 1
  #Window_LiberSort
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  ; Window_LiberSort
  #Gadget_LiberSort_fmain
  #Gadget_LiberSort_pwork
  #Gadget_LiberSort_twork
  #Gadget_LiberSort_terror
  #Gadget_LiberSort_ftosortfrom
  #Gadget_LiberSort_tosortfrom
  #Gadget_LiberSort_ftosortto
  #Gadget_LiberSort_tosortto
  #Gadget_LiberSort_fgetsortfiles
  #Gadget_LiberSort_getsortfiles
  #Gadget_LiberSort_fgettargetdir
  #Gadget_LiberSort_gettargetdir
  #Gadget_LiberSort_frunjob
  #Gadget_LiberSort_runjob
  #Gadget_LiberSort_flabels
  #Gadget_LiberSort_lsourcedir
  #Gadget_LiberSort_sourcedir
  #Gadget_LiberSort_ltargetdir
  #Gadget_LiberSort_targetdir
  #Gadget_LiberSort_fexit
  #Gadget_LiberSort_ferrors
  #Gadget_LiberSort_errors
  #Gadget_LiberSort_exit
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

; Image Constants

Enumeration 1
  #Image_LiberSort_twork
  #Image_LiberSort_terror
  #Image_LiberSort_getsortfiles
  #Image_LiberSort_gettargetdir
  #Image_LiberSort_runjob
  #Image_LiberSort_exit
EndEnumeration

#ImageIndex = #PB_Compiler_EnumerationValue

; Load Images

CatchImage(#Image_LiberSort_twork,        ?_OPT_LiberSort_twork)
CatchImage(#Image_LiberSort_terror,       ?_OPT_LiberSort_terror)
CatchImage(#Image_LiberSort_getsortfiles, ?_OPT_LiberSort_getsortfiles)
CatchImage(#Image_LiberSort_gettargetdir, ?_OPT_LiberSort_gettargetdir)
CatchImage(#Image_LiberSort_runjob,       ?_OPT_LiberSort_runjob)
CatchImage(#Image_LiberSort_exit,         ?_OPT_LiberSort_exit)

DataSection
  _OPT_LiberSort_twork        : IncludeBinary "Images\sort16x16.ico"
  _OPT_LiberSort_terror       : IncludeBinary "Images\errors16x16.ico"
  _OPT_LiberSort_getsortfiles : IncludeBinary "Images\folder cyan open 32x32.ico"
  _OPT_LiberSort_gettargetdir : IncludeBinary "Images\directory32x32.ico"
  _OPT_LiberSort_runjob       : IncludeBinary "Images\run32x32.ico"
  _OPT_LiberSort_exit         : IncludeBinary "Images\exit32x32.ico"
EndDataSection

;==================================================================================================
; 
;==================================================================================================

Procedure.l Window_LiberSort()
  If OpenWindow(#Window_LiberSort, 21, 64, 865, 655, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
      Frame3DGadget(#Gadget_LiberSort_fmain, 5, 0, 855, 645, "")
      PanelGadget(#Gadget_LiberSort_pwork, 15, 15, 835, 620)
      AddGadgetItem(#Gadget_LiberSort_pwork, -1, "  Main work form", ImageID(#Image_LiberSort_twork))
      Frame3DGadget(#Gadget_LiberSort_ftosortfrom, 5, 0, 255, 510, "")
      ListIconGadget(#Gadget_LiberSort_tosortfrom, 15, 15, 235, 485, "Source files", 231, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        SetGadgetFont(#Gadget_LiberSort_tosortfrom, LoadFont(#Gadget_LiberSort_tosortfrom, "Arial", 10, 0))
      Frame3DGadget(#Gadget_LiberSort_ftosortto, 265, 0, 560, 510, "")
      ListIconGadget(#Gadget_LiberSort_tosortto, 275, 15, 540, 485, "Category", 233, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        AddGadgetColumn(#Gadget_LiberSort_tosortto, 1, "Filename", 233)
        AddGadgetColumn(#Gadget_LiberSort_tosortto, 2, "Status", 70)
        SetGadgetFont(#Gadget_LiberSort_tosortto, LoadFont(#Gadget_LiberSort_tosortto, "Arial", 10, 0))
      Frame3DGadget(#Gadget_LiberSort_fgetsortfiles, 5, 515, 60, 70, "")
      ButtonImageGadget(#Gadget_LiberSort_getsortfiles, 15, 535, 40, 40, ImageID(#Image_LiberSort_getsortfiles))
      Frame3DGadget(#Gadget_LiberSort_fgettargetdir, 70, 515, 60, 70, "")
      ButtonImageGadget(#Gadget_LiberSort_gettargetdir, 80, 535, 40, 40, ImageID(#Image_LiberSort_gettargetdir))
      Frame3DGadget(#Gadget_LiberSort_frunjob, 135, 515, 60, 70, "")
      ButtonImageGadget(#Gadget_LiberSort_runjob, 145, 535, 40, 40, ImageID(#Image_LiberSort_runjob))
      Frame3DGadget(#Gadget_LiberSort_flabels, 200, 515, 560, 70, "")
      TextGadget(#Gadget_LiberSort_lsourcedir, 210, 530, 45, 15, "Source")
        SetGadgetFont(#Gadget_LiberSort_lsourcedir, LoadFont(#Gadget_LiberSort_lsourcedir, "Arial", 10, 0))
      StringGadget(#Gadget_LiberSort_sourcedir, 260, 530, 490, 20, "", #PB_String_ReadOnly)
        SetGadgetFont(#Gadget_LiberSort_sourcedir, LoadFont(#Gadget_LiberSort_sourcedir, "Arial", 8, 0))
      TextGadget(#Gadget_LiberSort_ltargetdir, 210, 555, 45, 15, "Target")
        SetGadgetFont(#Gadget_LiberSort_ltargetdir, LoadFont(#Gadget_LiberSort_ltargetdir, "Arial", 10, 0))
      StringGadget(#Gadget_LiberSort_targetdir, 260, 555, 490, 20, "", #PB_String_ReadOnly)
        SetGadgetFont(#Gadget_LiberSort_targetdir, LoadFont(#Gadget_LiberSort_targetdir, "Arial", 8, 0))
      Frame3DGadget(#Gadget_LiberSort_fexit, 765, 515, 60, 70, "")
      ButtonImageGadget(#Gadget_LiberSort_exit, 775, 535, 40, 40, ImageID(#Image_LiberSort_exit))
      AddGadgetItem(#Gadget_LiberSort_pwork, -1, "  Errors and status information", ImageID(#Image_LiberSort_terror))
      Frame3DGadget(#Gadget_LiberSort_ferrors, 5, 0, 820, 590, "")
      ListIconGadget(#Gadget_LiberSort_errors, 15, 15, 800, 565, "Status message", 140, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        AddGadgetColumn(#Gadget_LiberSort_errors, 1, "Explanation", 656)
        SetGadgetFont(#Gadget_LiberSort_errors, LoadFont(#Gadget_LiberSort_errors, "Arial", 10, 0))
      CloseGadgetList()
      HideWindow(#Window_LiberSort, 0)
      ProcedureReturn WindowID(#Window_LiberSort)
  EndIf
EndProcedure

;==================================================================================================
; Constants for statusbar handling and colouring
;==================================================================================================

#SB_SETBKCOLOR                  = $2001                                                 ; Statusbar colour constant

;==================================================================================================
; My personal constants
;==================================================================================================

#Author                         = "Miklós G Bolváry"                                    ; Author's name
#CopyRight                      = "PeriTek Visions 2010"                                ; Copyright holder
#Version                        = "v0.00"                                               ; Program version

#Regstring                      = " --* Freeware *-- "                                  ; Registration string

#Basename                       = "LiberSort "                                          ; Base name for ini and dataabse
#Program                        = #Basename + #Version + #Regstring                     ; Copyright string
#Traynote                       = #Basename + #Version                                  ; Copyright string
#Eol                            = Chr(13) + Chr(10)                                     ; End of line marker

#TitleTime                      = 1
  
;==================================================================================================
; Tooltip structure data
;==================================================================================================

Structure ToolTipData                                                                   ; If any tooltips setup, keep track of gadgets that have them so you can remove them if needed
  Window.i
  Gadget.i
  Handle.i
EndStructure

;==================================================================================================
; All program variables
;==================================================================================================

Structure ProgramData
  QuitValue.i                                                                           ; Program quit flag
  Mutex.i                                                                               ; Open window flag  

  TrayState.i                                                                           ; Is the form minimised to the system tray

  ColourToggle.i                                                                        ; Alternate list display banding
  
  ToolTips.i                                                                            ; Tool tips on or off
  FormFade.i                                                                            ; Save the window animation state
  ScreenSnap.i                                                                          ; Save screen snapping state
  TitleTime.i                                                                           ; Is the timer supposed to be on or off
  
  CurrentDir.s                                                                          ; The current directory
  
  WindowTitle.s                                                                         ; The main window title
EndStructure

;==================================================================================================
; Custom date routine structure
;==================================================================================================

Structure DateStructure                                                                ; Custom date routine
  Year.w
  Month.w
  DayOfWeek.w
  Day.w
  Hour.w
  Minute.w
  Second.w
  Milliseconds.w
EndStructure

;==================================================================================================
; LiberSort index structure
;==================================================================================================

Structure IndexData
  Directory.s
  BaseFilename.s
EndStructure

;==================================================================================================
; Any global variables, lists etc
;==================================================================================================

Global Program.ProgramData                                                              ; Structure to hold program data

Global NewList Index.IndexData()

Global NewList FoundDirs.s()                                                           ; List of dirs found by the search engine

Global NewList ToolTips.ToolTipData()                                                  ; All tool tip handles and data here

Global td.SYSTEMTIME                                                                    ; This is used as interface for time and date conversions

Global TitleString.s                                                                    ; The old window title string

;==================================================================================================
; NetMaestro's screen snap code
;==================================================================================================

Global screenW, screenH, SnapD = 50, AutoSnap = #True                                   ;

SystemParametersInfo_(#SPI_GETWORKAREA, 0, @wa.RECT, 0)                                  ; Client area of the desktop

ScreenW = wa\right                                                                       ;

screenH = wa\bottom                                                                      ;

;==================================================================================================
; Get working directories variables and create the physical dirs that go with them
;==================================================================================================

Program\CurrentDir    = GetCurrentDirectory()                                           ; Get the current directory name

;==================================================================================================
; Setup day and month literal names
;==================================================================================================

Global Dim NameOfDay.s(7)                                                               ; Fill an array with the names of the days (Terry Hough I think)

   NameOfDay(0)      = "Sunday"
   NameOfDay(1)      = "Monday"
   NameOfDay(2)      = "Tuesday"
   NameOfDay(3)      = "Wednesday"
   NameOfDay(4)      = "Thursday"
   NameOfDay(5)      = "Friday"
   NameOfDay(6)      = "Saturday"

Global Dim DaysPerMonth(12)                                                             ; Fill an array on how many days per month there are

  For X = 0 To 11     
    DaysPerMonth(X) = 31 
  Next

  DaysPerMonth(1)   = 28
  DaysPerMonth(3)   = 30
  DaysPerMonth(5)   = 30
  DaysPerMonth(8)   = 30
  DaysPerMonth(10)  = 30

Global Dim NameOfMonth.s(12)                                                            ; Fill an array with the names of the months

  NameOfMonth(0)    = "January"
  NameOfMonth(1)    = "February"
  NameOfMonth(2)    = "March"
  NameOfMonth(3)    = "April"
  NameOfMonth(4)    = "May"
  NameOfMonth(5)    = "June"
  NameOfMonth(6)    = "July"
  NameOfMonth(7)    = "August"
  NameOfMonth(8)    = "September"
  NameOfMonth(9)    = "October"
  NameOfMonth(10)   = "November"
  NameOfMonth(11)   = "December"

Global Dim Years.s(7)                                                                   ; Fill an array with the years

  Years(0)          = "2002"
  Years(1)          = "2003"
  Years(2)          = "2004"
  Years(3)          = "2005"
  Years(4)          = "2006" 
  Years(5)          = "2007"
  Years(6)          = "2008"

;==================================================================================================
; All my shortcuts and other things
;==================================================================================================

Enumeration #GadgetIndex
  #Systray_LiberSort_Tray                                                               ; Program tray constant
  #Shortcut_LiberSort_Exit                                                              ; 
EndEnumeration

;==================================================================================================
; All my image constants
;==================================================================================================

Enumeration #ImageIndex
  #Image_LiberSort_Tray                                                                 ; Program tray icon
EndEnumeration

;==================================================================================================
; Catch images from memory
;==================================================================================================

CatchImage(#Image_LiberSort_Tray,               ?_PTK_LiberSort_Tray)                    ; database16x16.ico         Minimised tray icon

;==================================================================================================
; Include images in the exe file
;==================================================================================================

DataSection
  _PTK_LiberSort_Tray        : IncludeBinary "Images\Analyse16x16.ico"                  ; 
EndDataSection

;==================================================================================================
; 
;==================================================================================================

Declare   GetSourceDirectory()
Declare   GetSourceFiles()
Declare   GetTargetDirectory()
Declare   SortFiles()
Declare   LastLine(Gadget, LineNumber)

;====================================================================================================
; Universal, recursive search engine
;====================================================================================================

Procedure GetSourceDirectory()
  SourceDir.s = PathRequester("LiberKey data path", "")
  If SourceDir.s
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Setting source" + Chr(10) +  "<°)))o><²³  Setting source directory " + SourceDir.s)
    SetGadgetText(#Gadget_LiberSort_sourcedir, SourceDir.s)
    GetSourceFiles()
  Else
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Source abort" + Chr(10) +  "<°)))o><²³  User didn't bother to select a source path or already exists")
  EndIf
EndProcedure

;====================================================================================================
; Universal, recursive search engine
;====================================================================================================

Procedure GetSourceFiles()
  If CountGadgetItems(#Gadget_LiberSort_tosortfrom) <> 0
    ClearGadgetItems(#Gadget_LiberSort_tosortfrom)
  EndIf
  SearchDir.s = GetGadgetText(#Gadget_LiberSort_sourcedir)
  If SearchDir.s
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Fetching files" + Chr(10) + "<°)))o><²³  Retrieving files from " + SearchDir.s)
    SetGadgetText(#Gadget_LiberSort_sourcedir, SearchDir.s)
    ClearList(FoundDirs.s())
    If SearchDir.s <> ""
      If Right(SearchDir.s, 1) = "\"
        SearchDir.s = Left(SearchDir.s, Len(SearchDir.s) - 1)
      EndIf
      AddElement(FoundDirs.s())
      FoundDirs.s() = SearchDir.s
      Index = 0
      Repeat
        SelectElement(FoundDirs.s(), Index)
        Directory = ExamineDirectory(#PB_Any, FoundDirs.s(), "*.*")
        If Directory
          Path.s = FoundDirs.s() + "\"
          While NextDirectoryEntry(Directory)
            Filename.s = DirectoryEntryName(Directory)
            Select DirectoryEntryType(Directory)
              Case 1
                While WindowEvent() : Wend
                If LCase(GetExtensionPart(Path + Filename)) = "lks"
                  Counter + 1
                  AddGadgetItem(#Gadget_LiberSort_tosortfrom, -1, FileName.s)
                  SetWindowTitle(#Window_LiberSort, Program\WindowTitle + Str(Counter) + " Files found")
                  ; Colour alternate lines in grey shades of colour
                  If Program\ColourToggle = 1
                    Program\ColourToggle = 0
                    SetGadgetItemColor(#Gadget_LiberSort_tosortfrom, Counter -1, #PB_Gadget_BackColor, $D4D4D4)
                  ElseIf Program\ColourToggle = 0
                    Program\ColourToggle = 1
                    SetGadgetItemColor(#Gadget_LiberSort_tosortfrom, Counter -1, #PB_Gadget_BackColor, $C1C1C1)
                  EndIf
                EndIf
              Case 2
                Filename.s = DirectoryEntryName(Directory)
                If Filename.s <> ".." And Filename.s <> "."
                  AddElement(FoundDirs())
                  FoundDirs() = Path + Filename.s
                EndIf
            EndSelect
          Wend
          FinishDirectory(Directory)
        EndIf
        Index + 1
      Until Index > ListSize(FoundDirs()) -1
    EndIf
  Else
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Source abort" + Chr(10) + "<°)))o><²³  The selected directory to search is empty")
  EndIf
EndProcedure

;==================================================================================================
; 
;==================================================================================================

Procedure GetTargetDirectory()
  TargetDir.s = PathRequester("LiberKey data path", "")
  If TargetDir.s
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Setting target" + Chr(10) + "<°)))o><²³  Setting target directory " + TargetDir.s)
    SetGadgetText(#Gadget_LiberSort_targetdir, TargetDir.s)
  Else
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Target abort" + Chr(10) + "<°)))o><²³  User didn't bother to select a target path or it already exists")
  EndIf
EndProcedure

;==================================================================================================
; 
;==================================================================================================

Procedure SortFiles()
  SourceDir.s = GetGadgetText(#Gadget_LiberSort_sourcedir)
  TargetDir.s = GetGadgetText(#Gadget_LiberSort_targetdir)
  If SourceDir.s <> TargetDir.s
    If TargetDir.s 
      NumFiles = CountGadgetItems(#Gadget_LiberSort_tosortfrom) - 1
      For SortLoop = NumFiles To 0 Step -1
        CurrentFile.s = GetGadgetItemText(#Gadget_LiberSort_tosortfrom, SortLoop)
        ForEach(Index())
          If FindString(CurrentFile.s, Index()\BaseFilename, 1)
            TargetDirString.s = TargetDir.s + Index()\Directory + "\"
            If MakeSureDirectoryPathExists_(TargetDirString.s) = #True
              If CopyFile(SourceDir.s + CurrentFile.s, TargetDirString.s + CurrentFile.s)
                Counter + 1
                While WindowEvent() : Wend
                AddGadgetItem(#Gadget_LiberSort_tosortto, -1, Index()\Directory + Chr(10) + Index()\BaseFilename + Chr(10) + "Okay")
                SetWindowTitle(#Window_LiberSort, Program\WindowTitle +  Str(Counter) + " " + CurrentFile.s)
                DeleteFile(SourceDir.s + CurrentFile.s)
                RemoveGadgetItem(#Gadget_LiberSort_tosortfrom, SortLoop)
                LastLine(#Gadget_LiberSort_tosortto, Counter - 1)
              Else
                AddGadgetItem(#Gadget_LiberSort_errors, -1, "Cannot move" + Chr(10) + SourceDir.s + CurrentFile.s)
              EndIf
            Else
              AddGadgetItem(#Gadget_LiberSort_errors, -1, "Dir create fail" + Chr(10) + "<°)))o><²³  Cannot create " + TargetDirString.s)
            EndIf
          Else
            ; String not found. Discard and try next one
          EndIf
        Next
      Next SortLoop
    Else
      AddGadgetItem(#Gadget_LiberSort_errors, -1, "Sort aborted" + Chr(10) + "<°)))o><²³  Target sort directory was not specified")
    EndIf
  Else
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Sort disallowed" + Chr(10) + "<°)))o><²³  The source and target directories must not be the same, bad things can happen")
  EndIf
EndProcedure


;==================================================================================================
; 
;==================================================================================================

Procedure SortFiles()
  SourceDir.s = GetGadgetText(#Gadget_LiberSort_sourcedir)
  TargetDir.s = GetGadgetText(#Gadget_LiberSort_targetdir)
  If SourceDir.s <> TargetDir.s
    If TargetDir.s 
      NumFiles = CountGadgetItems(#Gadget_LiberSort_tosortfrom) - 1
      For SortLoop = NumFiles To 0 Step -1
        CurrentFile.s = GetGadgetItemText(#Gadget_LiberSort_tosortfrom, SortLoop)
        ForEach(Index())
          If FindString(CurrentFile.s, Index()\BaseFilename, 1)
            TargetDirString.s = TargetDir.s + Index()\Directory + "\"
            If MakeSureDirectoryPathExists_(TargetDirString.s) = #True
              If CopyFile(SourceDir.s + CurrentFile.s, TargetDirString.s + CurrentFile.s)
                Counter + 1
                While WindowEvent() : Wend
                AddGadgetItem(#Gadget_LiberSort_tosortto, -1, Index()\Directory + Chr(10) + Index()\BaseFilename + Chr(10) + "Okay")
                SetWindowTitle(#Window_LiberSort, Program\WindowTitle +  Str(Counter) + " " + CurrentFile.s)
                DeleteFile(SourceDir.s + CurrentFile.s)
                RemoveGadgetItem(#Gadget_LiberSort_tosortfrom, SortLoop)
                LastLine(#Gadget_LiberSort_tosortto, Counter - 1)
              Else
                AddGadgetItem(#Gadget_LiberSort_errors, -1, "Cannot move" + Chr(10) + SourceDir.s + CurrentFile.s)
              EndIf
            Else
              AddGadgetItem(#Gadget_LiberSort_errors, -1, "Dir create fail" + Chr(10) + "<°)))o><²³  Cannot create " + TargetDirString.s)
            EndIf
          Else
            ; String not found. Discard and try next one
          EndIf
        Next
      Next SortLoop
    Else
      AddGadgetItem(#Gadget_LiberSort_errors, -1, "Sort aborted" + Chr(10) + "<°)))o><²³  Target sort directory was not specified")
    EndIf
  Else
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Sort disallowed" + Chr(10) + "<°)))o><²³  The source and target directories must not be the same, bad things can happen")
  EndIf
EndProcedure


;==================================================================================================
; 
;==================================================================================================

If Window_LiberSort()
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  AddGadgetItem(#Gadget_LiberSort_errors, -1, "Startup" + Chr(10) + "<°)))o><²³  " + #Program + "Ready to work")
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  ConfigFile = ReadFile(#PB_Any, Program\CurrentDir + "Directories.lbc")
  
  If ConfigFile
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Read Config" + Chr(10) + "<°)))o><²³  Sort from and to directories read from config")
    SetGadgetText(#Gadget_LiberSort_sourcedir, ReadString(ConfigFile))
    SetGadgetText(#Gadget_LiberSort_targetdir, ReadString(ConfigFile))
    CloseFile(ConfigFile)
  EndIf
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  IndexHandle = ReadFile(#PB_Any, Program\CurrentDir + "LiberSort.Idx")
  
  If Indexhandle
    AddGadgetItem(#Gadget_LiberSort_errors, -1, "Index load" + Chr(10) + "<°)))o><²³  Liberkey file sort index list loaded")
    While Eof(Indexhandle) = 0
      CurrentLine.s = ReadString(Indexhandle)
      AddElement(Index())
      Index()\Directory    = StringField(CurrentLine.s, 1, "|")
      Index()\BaseFilename = StringField(CurrentLine.s, 2, "|")
    Wend
    CloseFile(IndexHandle)
  Else
    End
  EndIf

  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  SetWindowTitle(#Window_LiberSort, "<°)))o><²³  " + #Program)
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  Program\WindowTitle =  "<°)))o><²³  " + #Program
   
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  Program\QuitValue  = 0
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  GetSourceFiles()
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Select EventWindow()
          Case #Window_LiberSort              : Program\QuitValue  = 1
        EndSelect
      Case #PB_Event_Menu
        Select EventMenu()
          Case #Shortcut_LiberSort_Exit       : Program\QuitValue  = 1
        EndSelect
      Case #PB_Event_Gadget
        Select EventGadget()
          Case #Gadget_LiberSort_getsortfiles : GetSourceDirectory()
          Case #Gadget_LiberSort_gettargetdir : GetTargetDirectory()
          Case #Gadget_LiberSort_runjob       : GetSourceFiles() : SortFiles()
          Case #Gadget_LiberSort_exit         : Program\QuitValue = 1
        EndSelect
    EndSelect
  Until Program\QuitValue = 1
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  ConfigFile = CreateFile(#PB_Any, Program\CurrentDir + "Directories.lbc")
  
  If ConfigFile
    WriteStringN(ConfigFile, GetGadgetText(#Gadget_LiberSort_sourcedir))
    WriteStringN(ConfigFile, GetGadgetText(#Gadget_LiberSort_targetdir))
    CloseFile(ConfigFile)
  EndIf
  
  ;------------------------------------------------------------------------------------------------
  ; 
  ;------------------------------------------------------------------------------------------------
  
  CloseWindow(#Window_LiberSort)
  
EndIf

End
Save this list below as "LiberSort.Idx" in the same directory that you intend to run the sorter in.
_Audio\_Converter|Format_
_Audio\_Converter|XMedia_Recode_
_Audio\_Editor|Audacity_
_Audio\_Editor|mp3DirectCut_
_Audio\_Editor|MP3Gain_
_Audio\_Editor|Wavosaur_
_Audio\_Ipod_Manager|CopyTrans_Manager_
_Audio\_Ipod_Manager|Floola_
_Audio\_Ipod_Manager|SharePod_
_Audio\_Player|AIMP_
_Audio\_Player|Soundbase_
_Audio\_Player|XMPlay_
_Audio\_Radio|ICY_Radio_
_Audio\_Radio|RadioSure_
_Audio\_Radio|Screamer_
_Audio\_Ripper|BonkEnc_
_Audio\_Tagger|Mp3tag_
_Audio\_Tagger|TagScanner_
_Audio\_Text_To_Speech|DSpeech_
_Audio\_Tools|Audio_Identifier_
_Audio\_Tools|Tunatic_
_Cd and dvd\_Burning_Tools|Amok_CD-DVD_Burning_
_Cd and dvd\_Burning_Tools|CDBurnerXP_
_Cd and dvd\_Burning_Tools|ImgBurn_
_Cd and dvd\_Burning_Tools|InfraRecorder_
_Cd and dvd\_Cover_Printer|UnderCoverXP_
_Cd and dvd\_Image_Tools|AnyToISO_Converter_
_Cd and dvd\_Image_Tools|Folder2Iso_
_Cd and dvd\_Image_Tools|LCISOCreator_
_Cd and dvd\_Image_Tools|Virtual_CDRom_Control_Panel_
_Education\_Astronomy|Celestia_
_Education\_Astronomy|Stellarium_
_Education\_Typing|RapidTyping_
_Education\_Drawing|TuxPaint_
_File manager\_Backup|Abakt_
_File manager\_Backup|USB_Image_Tool_
_File manager\_Cataloguer|CdCat_
_File manager\_Comparison|KDiff3_
_File manager\_Comparison|WinMerge_
_File manager\_Compression|7-Zip_
_File manager\_Compression|IZArc2Go_
_File manager\_Compression|PeaZip_
_File manager\_Compression|Universal_Extractor_
_File manager\_Copy|TeraCopy_
_File manager\_Defragmenter|Defraggler_
_File manager\_Defragmenter|Disk_Defrag_
_File manager\_Defragmenter|UltraDefrag_
_File manager\_Directory_Lister|DirHTML_
_File manager\_Disk_Space_Tool|FilePro_
_File manager\_Disk_Space_Tool|Folder_Size_
_File manager\_Disk_Space_Tool|Windirstat_
_File manager\_Duplicate_Killer|DupKiller_
_File manager\_Manager|Free_Commander_
_File manager\_Manager|Q-Dir_
_File manager\_Recovery|DiskDigger_
_File manager\_Recovery|Free_Data_Recovery_Software_
_File manager\_Recovery|Recuva_
_File manager\_Recovery|Roadkil's_Unstoppable_Copier_
_File manager\_Renamer|Ant_Renamer_
_File manager\_Renamer|Bulk_Rename_Utility_
_File manager\_Renamer|ReNamer_
_File manager\_Search|Everything_
_File manager\_Search|SearchMyFiles_
_File manager\_Splitter|GSplit_
_File manager\_Splitter|YoyoCut_
_File manager\_Synchronization|DSynchronize_
_File manager\_Synchronization|FreeFileSync_
_File manager\_Tools|NewFileTime_
_File manager\_Universal_Viewer|Universal_Viewer_
_Game\_Action|Neverball_
_Game\_Action|Trackballs_
_Game\_Card|PokerTH_
_Game\_Puzzle|Jooleem_
_Game\_Puzzle|Lines95_
_Game\_Puzzle|Pathological_
_Game\_Puzzle|Simple_Sudoku_
_Game\_Reflexion|Yea_Chess_
_Game\_Strategy|Bombermaaan_
_Graphics\_3D|Anim8or_
_Graphics\_3D|Blender_
_Graphics\_Colour_Picker|Color_Mania_
_Graphics\_Colour_Picker|ColorPic_
_Graphics\_Editor|GIMP_
_Graphics\_Editor|Inkscape_
_Graphics\_Editor|MyPaint_
_Graphics\_Editor|Paint.NET_
_Graphics\_Editor|Photo_Filtre_
_Graphics\_Effect_And_Filter|FotoSketcher_
_Graphics\_Icon_Editor|Greenfish_Icon_Editor_Pro_
_Graphics\_Icon_Editor|IcoFX_
_Graphics\_Screen_Capture|FastStone_Capture_
_Graphics\_Screen_Capture|PicPick_
_Graphics\_Tools|On-Screen_Ruler_
_Graphics\_Tools|PngOptimizer_
_Graphics\_Tools|RIOT_
_Graphics\_Vector_Converter|WinTopo_
_Graphics\_Viewer|FastStone_Image_Viewer_
_Graphics\_Viewer|IrfanView_
_Graphics\_Viewer|XnView_
_Internet\_Bookmark_Manager|Transmute_
_Internet\_Browser|Google_Chrome_
_Internet\_Browser|Chromium_
_Internet\_Browser|Firefox_
_Internet\_Browser|Opera_
_Internet\_Browser|QtWeb_
_Internet\_Download|eMule_
_Internet\_Download|Free_Download_Manager_
_Internet\_Download|uTorrent_
_Internet\_Email|POP_Peeper_
_Internet\_Email|PopTray_
_Internet\_Email|Thunderbird_
_Internet\_Ftp|FileZilla_
_Internet\_Instant_Messenger|aMSN_
_Internet\_Instant_Messenger|Miranda_IM_
_Internet\_Instant_Messenger|Pidgin_
_Internet\_Internet_Relay_Chat|MegaIRC_
_Internet\_Rss_Reader|GreatNews_
_Internet\_Website_Authoring|iWebAlbum_
_Internet\_Website_Authoring|KompoZer_
_Internet\_Website_Authoring|MobaPhoto_
_Internet\_Webste_Copier|HTTrack_
_Networking - server\_Bandwidth_Monitor|NetMeter_
_Networking - server\_Bandwidth_Monitor|NetWorx_
_Networking - server\_Configuration|B.I.S.S._Hosts_Manager_
_Networking - server\_Configuration|PE_Network_Configurator_
_Networking - server\_Network_Analyser|SmartSniff_
_Networking - server\_Network_Analyser|Yale_
_Networking - server\_Remote_Control|TeamViewer_
_Networking - server\_Remote_Control|UltraVNC_Server_
_Networking - server\_Remote_Control|UltraVNC_Viewer_
_Networking - server\_Scanner|SoftPerfect_Network_Scanner_
_Networking - server\_Scanner|Performance_Pinging_
_Networking - server\_Server|HFS_
_Networking - server\_Settings_Manager|Net_Profiles_
_Networking - server\_Settings_Manager|NetSetMan_
_Networking - server\_Telnet_Ssh_Client|KiTTY_(PuTTY)_
_Networking - server\_Telnet_Ssh_Client|TeraTerm_Pro_
_Networking - server\_Telnet_Ssh_Client|WinSCP_
_Networking - server\_Tools|CurrPorts_
_Networking - server\_Tools|DShutdown_
_Networking - server\_Tools|eToolz_
_Networking - server\_Tools|IP2_
_Networking - server\_Tools|IPNetInfo_
_Networking - server\_Tools|Network_Stuff_
_Office\_Calculator|ESBCalc_
_Office\_Calculator|MyCalc2_
_Office\_Calculator|SpeedCrunch_
_Office\_Calendar|EssentialPIM_
_Office\_Calendar|Rainlendar_Lite_
_Office\_Calendar|Sunbird_
_Office\_Chrono|Pc_Chrono_
_Office\_Desktop_Tools\_Application_Launcher|Executor_
_Office\_Desktop_Tools\_Application_Launcher|RocketDock_
_Office\_Desktop_Tools\_Automation|AutoHotkey_
_Office\_Desktop_Tools\_Automation|Clavier+_
_Office\_Desktop_Tools\_Clipboard_Manager|Clipboardic_
_Office\_Desktop_Tools\_Clipboard_Manager|Ditto_
_Office\_Desktop_Tools\_Clock|ClocX_
_Office\_Desktop_Tools\_Clock|TimeSync_
_Office\_Desktop_Tools\_Customisation|Shock_Caption_
_Office\_Desktop_Tools\_Notes|PNotes_
_Office\_Desktop_Tools\_Notes|Stickies_
_Office\_Desktop_Tools\_Keyboard_And_Mouse|Click-N-Type_
_Office\_Desktop_Tools\_Save_Desktop_Icon|DesktopOK_
_Office\_Desktop_Tools\_Save_Desktop_Icon|Shock_Desktop_
_Office\_Desktop_Tools\_Virtual_Desktop|VirtuaWin_
_Office\_Desktop_Tools\_Zoom|Virtual_Magnifying_Glass_
_Office\_Desktop_Tools\_Zoom|ZoomIt_
_Office\_Diagram_Editor|Dia_
_Office\_Diagram_Editor|Diagram_Designer_
_Office\_Finance_Manager|Money_Manager_
_Office\_Finance_Manager|viCompte_
_Office\_Font_Manager|AMP_Font_Viewer_
_Office\_Font_Manager|FontList_
_Office\_Font_Manager|NexusFont_
_Office\_Note_Manager|TreeDBNotes_
_Office\_Office_Suite|AbiWord_
_Office\_Office_Suite|OpenOffice.org_
_Office\_Office_Suite|Scribus_
_Office\_Pdf|Foxit_Reader_
_Office\_Pdf|PDFTK_Builder_
_Office\_Pdf|PDF-XChange_Viewer_
_Office\_Pdf|SumatraPDF_
_Office\_Presentation|Pointofix_
_Office\_Task_Manager|Task_Coach_
_Office\_Text_Editor|AkelPad_
_Office\_Text_Editor|Notepad++_
_Office\_Text_Editor|PSPad_
_Office\_Text_Editor|RJ_TextEd_
_Office\_Tutorial_Creator|vTute_Recorder_
_Office\_Tutorial_Creator|Wink_
_Office\_Unit_Converter|Converber_
_Office\_Unit_Converter|ESBUnitConv_
_Platform|LiberKey_
_Platform|LiberKey_Platform_
_Removed|ThrottleWatch_
_Removed|Visual_Tooltip_
_Removed|WinFlip_
_Security\_AntiVirus_And_Spyware|ClamWin_
_Security\_AntiVirus_And_Spyware|Runscanner_
_Security\_AntiVirus_And_Spyware|SpyDLLRemover_
_Security\_Encryption|DCU_
_Security\_Encryption|Omziff_
_Security\_Encryption|TrueCrypt_
_Security\_Integrity_Checker|HashCalc_
_Security\_Integrity_Checker|HashMyFiles_
_Security\_Password_Manager|KeePass_Classic_Edition_
_Security\_Password_Manager|KeePass_Professional_Edition_
_Security\_Password_Manager|Password_Generator_
_Security\_Privacy_Tool|XP-AntiSpy_
_Security\_Secure_Deletion|UltraShredder_
_Security\_Secure_Deletion|WipeDisk_
_Security\_Secure_Deletion|WipeFile_
_Security\_Tools|USB_WriteProtector_
_System utilities\_Benchmark\_HardDisk|CrystalDiskMark_
_System utilities\_Benchmark\_HardDisk|HD_Speed_
_System utilities\_Benchmark\_Universal|CrystalMark_
_System utilities\_Cleaner_Uninstaller|CCleaner_
_System utilities\_Cleaner_Uninstaller|CleanAfterMe_
_System utilities\_Cleaner_Uninstaller|Driver_Sweeper_
_System utilities\_Cleaner_Uninstaller|FCleaner_
_System utilities\_Cleaner_Uninstaller|FileASSASSIN_
_System utilities\_Cleaner_Uninstaller|Glary_Utilities_
_System utilities\_Cleaner_Uninstaller|JavaRa_
_System utilities\_Cleaner_Uninstaller|MUICacheView_
_System utilities\_Cleaner_Uninstaller|MyUninstaller_
_System utilities\_Cleaner_Uninstaller|Remove_Empty_Directories_
_System utilities\_Cleaner_Uninstaller|Revo_Uninstaller_
_System utilities\_Cleaner_Uninstaller|Unlocker_
_System utilities\_Cleaner_Uninstaller|Wise_Disk_Cleaner_
_System utilities\_Emulator|MobaLiveCD_
_System utilities\_Hex_Editor|HxD_
_System utilities\_Information\_File_Monitoring|OpenedFilesView_
_System utilities\_Information\_Hardware_Monitoring|HWMonitor_
_System utilities\_Information\_Inventory|HWINFO32_
_System utilities\_Information\_Inventory|PC_Wizard_
_System utilities\_Information\_Inventory|SIW_
_System utilities\_Information\_Inventory|Speccy_
_System utilities\_Information\_Inventory|System_Explorer_
_System utilities\_Information\_Inventory|System_Spec_
_System utilities\_Information\_Inventory|WinAudit_
_System utilities\_Information\_Process|Bill2's_Process_Manager_
_System utilities\_Information\_Process|DTaskManager_
_System utilities\_Information\_Process|Process_Explorer_
_System utilities\_Information\_Process|Process_Hacker_
_System utilities\_Information\_Processor|CPU-Z_
_System utilities\_Information\_Processor|CrystalCPUID_
_System utilities\_Information\_Processor|Slow_
_System utilities\_Information\_Service|ServiWin_
_System utilities\_Information\_Startup_Manager|Autoruns_
_System utilities\_Information\_Startup_Manager|Startup_Control_Panel_
_System utilities\_Information\_Usb_Device|USBDeview_
_System utilities\_Information\_Video_Card|GPU_Caps_Viewer_
_System utilities\_Information\_Video_Card|GPU-Z_
_System utilities\_Registry\_Backup|Erunt_
_System utilities\_Registry\_Comparison|Regshot_
_System utilities\_Registry\_Compression|NTREGOPT_
_System utilities\_Registry\_Compression|Quicksys_RegDefrag_
_System utilities\_Registry\_Monitoring|Process_Monitor_
_System utilities\_Registry\_Monitoring|RegFromApp_
_System utilities\_Registry\_Repair|Free_Window_Registry_Repair_
_System utilities\_Registry\_Repair|Wise_Registry_Cleaner_
_System utilities\_Registry\_Search|RegScanner_
_System utilities\_Repair|Partition_Find_and_Mount_
_System utilities\_Tests\_Burning_Test|HeavyLoad_
_System utilities\_Tests\_Burning_Test|OCCT_
_System utilities\_Tests\_Hard_Disk|CrystalDiskInfo_
_System utilities\_Tests\_Hard_Disk|HD_Tune_
_System utilities\_Tests\_Monitor|CheckeMON_
_System utilities\_Tests\_Monitor|Eizo_Monitortest_
_System utilities\_Tests\_Ram|MemTest_
_System utilities\_Tools|Autoplay_Repair_
_System utilities\_Tools|BlueScreenView_
_System utilities\_Tools|ColorConsole_
_System utilities\_Tools|Drive_Manager_
_System utilities\_Tools|Fast_Explorer_
_System utilities\_Tools|Fat32Formatter_
_System utilities\_Tools|FileTypesMan_
_System utilities\_Tools|Path_Editor_
_System utilities\_Tools|RAMRush_
_System utilities\_Tools|Rapid_Environment_Editor_
_System utilities\_Tools|RegDllView_
_System utilities\_Tools|ResourcesExtract_
_System utilities\_Tools|ShellExView_
_System utilities\_Tools|SysExporter_
_System utilities\_Tools|USB_Disk_Ejector_
_System utilities\_Tweaker|Tweak_UI_
_System utilities\_Tweaker|XdN_Tweaker_
_System utilities\_Tweaker|XP-Config_
_System utilities\_Update_Checker|Filehippo_Update_Checker_
_Video\_Authoring|DVDStyler_
_Video\_Capture|VDownloader_
_Video\_Capture|WebVideoCap_
_Video\_Capture|xVideoServiceThief_
_Video\_Cataloguer|Ant_Movie_Catalog_
_Video\_Converter|Pocket_Divx_Encoder_
_Video\_Editor|Avidemux_
_Video\_Editor|VirtualDub_
_Video\_Player|Media_Player_Classic_
_Video\_Player|MPC_HomeCinema_
_Video\_Player|VLC_media_player_
_Video\_Player|Wimpy_FLV_Player_
_Video\_Repair|DivFix++_
_Video\_Tools|Aspect_
_Video\_Tools|K-Lite_Codec_Tweak_Tool_
_Video\_Tools|Filmerit_
_Video\_Tools|GSpot_
_Video\_Tools|MediaInfo_
_Video\_Tools|VideoCalc_
LiberSort saves the directories that you chose as source and target for next time.

P.S You will have to get your own graphics, this project didn't warrant a package job.

Re: LiberKey offline files sorter

Posted: Wed Dec 07, 2011 10:14 am
by Fangbeast
Project updated to include PortableApps update files as well. All the apps are in a DataSection, all other settings in an INI files.

Don't have time for much explanation, have health issues. Part 1 of 2

Code: Select all

; Visual designer created constants

Enumeration 1
  #Window_PortaSort
EndEnumeration

#WindowIndex = #PB_Compiler_EnumerationValue

Enumeration 1
  ; Window_PortaSort
  #Gadget_PortaSort_fmain
  #Gadget_PortaSort_pwork
  #Gadget_PortaSort_tSortFiles
  #Gadget_PortaSort_tSetup
  #Gadget_PortaSort_tErrors
  #Gadget_PortaSort_fToSortFrom
  #Gadget_PortaSort_ToSortFrom
  #Gadget_PortaSort_fToSortTo
  #Gadget_PortaSort_ToSortTo
  #Gadget_PortaSort_fGetSortFiles
  #Gadget_PortaSort_GetSortFiles
  #Gadget_PortaSort_fRunJob
  #Gadget_PortaSort_RunJob
  #Gadget_PortaSort_fSelectIndex
  #Gadget_PortaSort_lSelectIndex
  #Gadget_PortaSort_SelectIndex
  #Gadget_PortaSort_fDirectories
  #Gadget_PortaSort_lSourceDir
  #Gadget_PortaSort_SourceDir
  #Gadget_PortaSort_lTargetDir
  #Gadget_PortaSort_TargetDir
  #Gadget_PortaSort_fExit
  #Gadget_PortaSort_Exit
  #Gadget_PortaSort_fliberkeysetup
  #Gadget_PortaSort_lLiberKeyPath
  #Gadget_PortaSort_lLiberkeySourceDir
  #Gadget_PortaSort_LiberkeySourceDir
  #Gadget_PortaSort_GetLiberkeySource
  #Gadget_PortaSort_lLiberkeyTargetDir
  #Gadget_PortaSort_LiberkeyTargetDir
  #Gadget_PortaSort_GetLiberkeyTarget
  #Gadget_PortaSort_fportableappssetup
  #Gadget_PortaSort_lPortableAppspaths
  #Gadget_PortaSort_lPortableAppsSourceDir
  #Gadget_PortaSort_PortableAppsSourceDir
  #Gadget_PortaSort_GetPortableAppsSource
  #Gadget_PortaSort_lPortableAppsTargetDir
  #Gadget_PortaSort_PortableAppsTargetDir
  #Gadget_PortaSort_GetPortableAppsTarget
  #Gadget_PortaSort_fother
  #Gadget_PortaSort_lOtherOptions
  #Gadget_PortaSort_oMove
  #Gadget_PortaSort_oCopy
  #Gadget_PortaSort_cbDumpLeftovers
  #Gadget_PortaSort_fspare
  #Gadget_PortaSort_ferrors
  #Gadget_PortaSort_errors
EndEnumeration

#GadgetIndex = #PB_Compiler_EnumerationValue

; Image Constants

Enumeration 1
  #Image_PortaSort_tSortFiles
  #Image_PortaSort_tSetup
  #Image_PortaSort_tErrors
  #Image_PortaSort_GetSortFiles
  #Image_PortaSort_RunJob
  #Image_PortaSort_Exit
EndEnumeration

#ImageIndex = #PB_Compiler_EnumerationValue

;- Load Images

CatchImage(#Image_PortaSort_tSortFiles,   ?_MGB_PortaSort_tSortFiles)
CatchImage(#Image_PortaSort_tSetup,       ?_MGB_PortaSort_tSetup)
CatchImage(#Image_PortaSort_tErrors,      ?_MGB_PortaSort_tErrors)
CatchImage(#Image_PortaSort_GetSortFiles, ?_MGB_PortaSort_GetSortFiles)
CatchImage(#Image_PortaSort_RunJob,       ?_MGB_PortaSort_RunJob)
CatchImage(#Image_PortaSort_Exit,         ?_MGB_PortaSort_Exit)

; 

DataSection
  _MGB_PortaSort_tSortFiles   : IncludeBinary "Images\directory16x16.ico"
  _MGB_PortaSort_tSetup       : IncludeBinary "Images\Analyse16x16.ico"
  _MGB_PortaSort_tErrors      : IncludeBinary "Images\errors16x16.ico"
  _MGB_PortaSort_GetSortFiles : IncludeBinary "Images\directory32x32.ico"
  _MGB_PortaSort_RunJob       : IncludeBinary "Images\run32x32.ico"
  _MGB_PortaSort_Exit         : IncludeBinary "Images\exit32x32.ico"
EndDataSection

; Visual designer created windows code

Procedure.l Window_PortaSort()
  If OpenWindow(#Window_PortaSort, -121, 71, 865, 655, "", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered|#PB_Window_Invisible)
    SetWindowColor(#Window_PortaSort, $DBDBDB)
      Frame3DGadget(#Gadget_PortaSort_fmain, 6, 0, 855, 650, "")
      PanelGadget(#Gadget_PortaSort_pwork, 15, 15, 835, 625)
      AddGadgetItem(#Gadget_PortaSort_pwork, -1, "  Main work form", ImageID(#Image_PortaSort_tSortFiles))
      Frame3DGadget(#Gadget_PortaSort_fToSortFrom, 5, 0, 255, 515, "")
      ListIconGadget(#Gadget_PortaSort_ToSortFrom, 15, 15, 235, 490, "Source files", 231, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        SetGadgetColor(#Gadget_PortaSort_ToSortFrom, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_ToSortFrom, LoadFont(#Gadget_PortaSort_ToSortFrom, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fToSortTo, 265, 0, 560, 515, "")
      ListIconGadget(#Gadget_PortaSort_ToSortTo, 275, 15, 540, 490, "Category", 233, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        SetGadgetColor(#Gadget_PortaSort_ToSortTo, #PB_Gadget_BackColor, $DBDBDB)
        AddGadgetColumn(#Gadget_PortaSort_ToSortTo, 1, "Filename", 233)
        AddGadgetColumn(#Gadget_PortaSort_ToSortTo, 2, "Status", 70)
        SetGadgetFont(#Gadget_PortaSort_ToSortTo, LoadFont(#Gadget_PortaSort_ToSortTo, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fGetSortFiles, 5, 520, 60, 70, "")
      ButtonImageGadget(#Gadget_PortaSort_GetSortFiles, 15, 535, 40, 40, ImageID(#Image_PortaSort_GetSortFiles))
      Frame3DGadget(#Gadget_PortaSort_fRunJob, 70, 520, 60, 70, "")
      ButtonImageGadget(#Gadget_PortaSort_RunJob, 80, 535, 40, 40, ImageID(#Image_PortaSort_RunJob))
      Frame3DGadget(#Gadget_PortaSort_fSelectIndex, 135, 520, 125, 70, "")
      TextGadget(#Gadget_PortaSort_lSelectIndex, 145, 530, 105, 15, "Select index")
        SetGadgetColor(#Gadget_PortaSort_lSelectIndex, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lSelectIndex, LoadFont(#Gadget_PortaSort_lSelectIndex, "Comic Sans MS", 10, 0))
      ComboBoxGadget(#Gadget_PortaSort_SelectIndex, 145, 550, 105, 25)
        SetGadgetColor(#Gadget_PortaSort_SelectIndex, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_SelectIndex, LoadFont(#Gadget_PortaSort_SelectIndex, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fDirectories, 265, 520, 495, 70, "")
      TextGadget(#Gadget_PortaSort_lSourceDir, 275, 535, 50, 20, "Source", #PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_lSourceDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lSourceDir, LoadFont(#Gadget_PortaSort_lSourceDir, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_PortaSort_SourceDir, 325, 535, 425, 20, "", #PB_String_ReadOnly|#PB_String_BorderLess)
        SetGadgetColor(#Gadget_PortaSort_SourceDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_SourceDir, LoadFont(#Gadget_PortaSort_SourceDir, "Comic Sans MS", 10, 0))
      TextGadget(#Gadget_PortaSort_lTargetDir, 275, 560, 50, 20, "Source", #PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_lTargetDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lTargetDir, LoadFont(#Gadget_PortaSort_lTargetDir, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_PortaSort_TargetDir, 325, 560, 425, 20, "", #PB_String_ReadOnly|#PB_String_BorderLess)
        SetGadgetColor(#Gadget_PortaSort_TargetDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_TargetDir, LoadFont(#Gadget_PortaSort_TargetDir, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fExit, 765, 520, 60, 70, "")
      ButtonImageGadget(#Gadget_PortaSort_Exit, 775, 535, 40, 40, ImageID(#Image_PortaSort_Exit))
      AddGadgetItem(#Gadget_PortaSort_pwork, -1, " Source and target paths setup", ImageID(#Image_PortaSort_tSetup))
      Frame3DGadget(#Gadget_PortaSort_fliberkeysetup, 5, 0, 820, 100, "")
      TextGadget(#Gadget_PortaSort_lLiberKeyPath, 20, 15, 790, 20, " LiberKey source and target paths")
        SetGadgetColor(#Gadget_PortaSort_lLiberKeyPath, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lLiberKeyPath, LoadFont(#Gadget_PortaSort_lLiberKeyPath, "Comic Sans MS", 10, 0))
      TextGadget(#Gadget_PortaSort_lLiberkeySourceDir, 20, 45, 50, 20, "Source", #PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_lLiberkeySourceDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lLiberkeySourceDir, LoadFont(#Gadget_PortaSort_lLiberkeySourceDir, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_PortaSort_LiberkeySourceDir, 70, 45, 710, 20, "", #PB_String_ReadOnly|#PB_String_BorderLess|#PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_LiberkeySourceDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_LiberkeySourceDir, LoadFont(#Gadget_PortaSort_LiberkeySourceDir, "Comic Sans MS", 10, 0))
      ButtonGadget(#Gadget_PortaSort_GetLiberkeySource, 785, 45, 25, 20, "...")
        SetGadgetFont(#Gadget_PortaSort_GetLiberkeySource, LoadFont(#Gadget_PortaSort_GetLiberkeySource, "Comic Sans MS", 10, 0))
      TextGadget(#Gadget_PortaSort_lLiberkeyTargetDir, 20, 70, 50, 20, "Target", #PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_lLiberkeyTargetDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lLiberkeyTargetDir, LoadFont(#Gadget_PortaSort_lLiberkeyTargetDir, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_PortaSort_LiberkeyTargetDir, 70, 70, 710, 20, "", #PB_String_ReadOnly|#PB_String_BorderLess|#PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_LiberkeyTargetDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_LiberkeyTargetDir, LoadFont(#Gadget_PortaSort_LiberkeyTargetDir, "Comic Sans MS", 10, 0))
      ButtonGadget(#Gadget_PortaSort_GetLiberkeyTarget, 785, 70, 25, 20, "...")
        SetGadgetFont(#Gadget_PortaSort_GetLiberkeyTarget, LoadFont(#Gadget_PortaSort_GetLiberkeyTarget, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fportableappssetup, 5, 100, 820, 100, "")
      TextGadget(#Gadget_PortaSort_lPortableAppspaths, 20, 115, 790, 20, " PortableApps source and target paths")
        SetGadgetColor(#Gadget_PortaSort_lPortableAppspaths, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lPortableAppspaths, LoadFont(#Gadget_PortaSort_lPortableAppspaths, "Comic Sans MS", 10, 0))
      TextGadget(#Gadget_PortaSort_lPortableAppsSourceDir, 20, 145, 50, 20, "Source", #PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_lPortableAppsSourceDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lPortableAppsSourceDir, LoadFont(#Gadget_PortaSort_lPortableAppsSourceDir, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_PortaSort_PortableAppsSourceDir, 70, 145, 710, 20, "", #PB_String_ReadOnly|#PB_String_BorderLess|#PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_PortableAppsSourceDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_PortableAppsSourceDir, LoadFont(#Gadget_PortaSort_PortableAppsSourceDir, "Comic Sans MS", 10, 0))
      ButtonGadget(#Gadget_PortaSort_GetPortableAppsSource, 785, 145, 25, 20, "...")
        SetGadgetFont(#Gadget_PortaSort_GetPortableAppsSource, LoadFont(#Gadget_PortaSort_GetPortableAppsSource, "Comic Sans MS", 10, 0))
      TextGadget(#Gadget_PortaSort_lPortableAppsTargetDir, 20, 170, 50, 20, "Target", #PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_lPortableAppsTargetDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lPortableAppsTargetDir, LoadFont(#Gadget_PortaSort_lPortableAppsTargetDir, "Comic Sans MS", 10, 0))
      StringGadget(#Gadget_PortaSort_PortableAppsTargetDir, 70, 170, 710, 20, "", #PB_String_ReadOnly|#PB_String_BorderLess|#PB_Text_Center)
        SetGadgetColor(#Gadget_PortaSort_PortableAppsTargetDir, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_PortableAppsTargetDir, LoadFont(#Gadget_PortaSort_PortableAppsTargetDir, "Comic Sans MS", 10, 0))
      ButtonGadget(#Gadget_PortaSort_GetPortableAppsTarget, 785, 170, 25, 20, "...")
        SetGadgetFont(#Gadget_PortaSort_GetPortableAppsTarget, LoadFont(#Gadget_PortaSort_GetPortableAppsTarget, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fother, 5, 200, 820, 79, "")
      TextGadget(#Gadget_PortaSort_lOtherOptions, 20, 215, 790, 20, " Copying or moving portable files around")
        SetGadgetColor(#Gadget_PortaSort_lOtherOptions, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_lOtherOptions, LoadFont(#Gadget_PortaSort_lOtherOptions, "Comic Sans MS", 10, 0))
      OptionGadget(#Gadget_PortaSort_oMove, 20, 245, 205, 20, "Move files to target path")
        SetGadgetColor(#Gadget_PortaSort_oMove, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_oMove, LoadFont(#Gadget_PortaSort_oMove, "Comic Sans MS", 10, 0))
      OptionGadget(#Gadget_PortaSort_oCopy, 230, 245, 205, 20, "Copy files to target path")
        SetGadgetColor(#Gadget_PortaSort_oCopy, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_oCopy, LoadFont(#Gadget_PortaSort_oCopy, "Comic Sans MS", 10, 0))
      CheckBoxGadget(#Gadget_PortaSort_cbDumpLeftovers, 440, 245, 370, 20, "Dump leftover files to a report log file in program dir")
        SetGadgetColor(#Gadget_PortaSort_cbDumpLeftovers, #PB_Gadget_BackColor, $DBDBDB)
        SetGadgetFont(#Gadget_PortaSort_cbDumpLeftovers, LoadFont(#Gadget_PortaSort_cbDumpLeftovers, "Comic Sans MS", 10, 0))
      Frame3DGadget(#Gadget_PortaSort_fspare, 5, 280, 820, 314, "")
      AddGadgetItem(#Gadget_PortaSort_pwork, -1, " Errors of the idiot programmer", ImageID(#Image_PortaSort_tErrors))
      Frame3DGadget(#Gadget_PortaSort_ferrors, 5, 0, 820, 595, "")
      ListIconGadget(#Gadget_PortaSort_errors, 15, 15, 800, 570, "Status message", 140, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection)
        SetGadgetColor(#Gadget_PortaSort_errors, #PB_Gadget_BackColor, $DBDBDB)
        AddGadgetColumn(#Gadget_PortaSort_errors, 1, "Explanation", 656)
        SetGadgetFont(#Gadget_PortaSort_errors, LoadFont(#Gadget_PortaSort_errors, "Comic Sans MS", 10, 0))
      CloseGadgetList()
      HideWindow(#Window_PortaSort, 0)
      ProcedureReturn WindowID(#Window_PortaSort)
  EndIf
EndProcedure

; Need a unicode aware version of the API directory creator

Import "shell32.lib"
  SHCreateDirectory(*hwnd, pszPath.p-unicode)
EndImport

; Constants for statusbar handling and colouring

#SB_SETBKCOLOR                  = $2001                                                 ; Statusbar colour constant

; My personal constants

#Author                         = "Miklos G Bolvary"                                    ; Author's name
#CopyRight                      = "MGB Technical Services"                              ; Copyright holder
#Basename                       = "PortaSort(c),  "                                     ; Base name for ini and database
#Version                        = "v0.00, "                                             ; Program version
#Regstring                      = " --* Freeware *-- "                                  ; Registration string

#Program                        = #Basename + #Version + #Regstring                     ; Copyright string
#Traynote                       = #Basename + #Version                                  ; Copyright string
#Eol                            = Chr(13) + Chr(10)                                     ; End of line marker

#TitleTime                      = 1

; Tooltip structure data

Structure ToolTipData                                                                   ; If any tooltips setup, keep track of gadgets that have them so you can remove them if needed
  Window.i
  Gadget.i
  Handle.i
EndStructure

; All program variables

Structure ProgramData
  QuitValue.i                                                                           ; Program quit flag
  Mutex.i                                                                               ; Open window flag  

  TrayState.i                                                                           ; Is the form minimised to the system tray

  ColourToggle.i                                                                        ; Alternate list display banding
  
  ToolTips.i                                                                            ; Tool tips on or off
  FormFade.i                                                                            ; Save the window animation state
  ScreenSnap.i                                                                          ; Save screen snapping state
  TitleTime.i                                                                           ; Is the timer supposed to be on or off
  
  CurrentDir.s                                                                          ; The current directory
  IniFile.s                                                                             ; The program preferences file
  LogFile.s                                                                             ; 
  
  WindowTitle.s                                                                         ; The main window title
  
  LiberkeySourcePath.s                                                                  ;                                                              ; 
  LiberKeyTargetPath.s                                                                  ; 
  PortableAppsSourcePath.s                                                              ; 
  PortableAppsTargetPath.s                                                              ; 
  
  LastIndex.s                                                                           ; Last portable index used
  FileMode.s                                                                            ; Copy or move files
  DumpLeftOvers.s                                                                       ; Dump leftover files to a report
EndStructure

; Custom date routine structure

Structure DateStructure                                                                ; Custom date routine
  Year.w
  Month.w
  DayOfWeek.w
  Day.w
  Hour.w
  Minute.w
  Second.w
  Milliseconds.w
EndStructure

; PortaSort index structure

Structure IndexData
  Directory.s
  BaseFilename.s
EndStructure

; Any global variables, lists etc

Global Program.ProgramData                                                              ; Structure to hold program data
Global NewList Index.IndexData()
Global NewList FoundDirs.s()                                                           ; List of dirs found by the search engine
Global NewList ToolTips.ToolTipData()                                                  ; All tool tip handles and data here
Global td.SYSTEMTIME                                                                    ; This is used as interface for time and date conversions
Global TitleString.s                                                                    ; The old window title string

; NetMaestro's screen snap code

Global screenW, screenH, SnapD = 50, AutoSnap = #True                                   ;
SystemParametersInfo_(#SPI_GETWORKAREA, 0, @wa.RECT, 0)                                  ; Client area of the desktop
ScreenW = wa\right                                                                       ;
screenH = wa\bottom                                                                      ;

; Get working directories variables and create the physical dirs that go with them

Program\CurrentDir    = GetCurrentDirectory()                                           ; Get the current directory name
Program\IniFile       = Program\CurrentDir  + "PortableFileSort.Ini"                    ; Name and path to the program ini file
Program\LogFile       = Program\CurrentDir  + "PortableFileSort.Log"                    ; Name and path to the program ini file

; Setup day and month literal names

Global Dim NameOfDay.s(7)                                                               ; Fill an array with the names of the days (Terry Hough I think)
   NameOfDay(0)      = "Sunday"
   NameOfDay(1)      = "Monday"
   NameOfDay(2)      = "Tuesday"
   NameOfDay(3)      = "Wednesday"
   NameOfDay(4)      = "Thursday"
   NameOfDay(5)      = "Friday"
   NameOfDay(6)      = "Saturday"
Global Dim DaysPerMonth(12)                                                             ; Fill an array on how many days per month there are
  For X = 0 To 11     
    DaysPerMonth(X) = 31 
  Next
  DaysPerMonth(1)   = 28
  DaysPerMonth(3)   = 30
  DaysPerMonth(5)   = 30
  DaysPerMonth(8)   = 30
  DaysPerMonth(10)  = 30
Global Dim NameOfMonth.s(12)                                                            ; Fill an array with the names of the months
  NameOfMonth(0)    = "January"
  NameOfMonth(1)    = "February"
  NameOfMonth(2)    = "March"
  NameOfMonth(3)    = "April"
  NameOfMonth(4)    = "May"
  NameOfMonth(5)    = "June"
  NameOfMonth(6)    = "July"
  NameOfMonth(7)    = "August"
  NameOfMonth(8)    = "September"
  NameOfMonth(9)    = "October"
  NameOfMonth(10)   = "November"
  NameOfMonth(11)   = "December"
Global Dim Years.s(7)                                                                   ; Fill an array with the years
  Years(0)          = "2002"
  Years(1)          = "2003"
  Years(2)          = "2004"
  Years(3)          = "2005"
  Years(4)          = "2006" 
  Years(5)          = "2007"
  Years(6)          = "2008"

; All my shortcuts and other things

Enumeration #GadgetIndex
  #Systray_PortaSort_Tray                                                               ; Program tray constant
  #Shortcut_PortaSort_Exit                                                              ; 
EndEnumeration

; All my image constants

Enumeration #ImageIndex
  #Image_PortaSort_Tray                                                                 ; Program tray icon
EndEnumeration

; Catch images from memory

CatchImage(#Image_PortaSort_Tray,               ?_PTK_PortaSort_Tray)                    ; database16x16.ico         Minimised tray icon

; Include images in the exe file

DataSection
  _PTK_PortaSort_Tray        : IncludeBinary "Images\Analyse16x16.ico"                  ; 
  
  _PTK_LiberKeySort_Data:
  Data.s "_Audio\_Converter|Format_"
  Data.s "_Audio\_Converter|XMedia_Recode_"
  Data.s "_Audio\_Editor|Audacity_"
  Data.s "_Audio\_Editor|mp3DirectCut_"
  Data.s "_Audio\_Editor|MP3Gain_"
  Data.s "_Audio\_Editor|Wavosaur_"
  Data.s "_Audio\_Ipod_Manager|CopyTrans_Manager_"
  Data.s "_Audio\_Ipod_Manager|Floola_"
  Data.s "_Audio\_Ipod_Manager|SharePod_"
  Data.s "_Audio\_Player|AIMP_"
  Data.s "_Audio\_Player|CoolPlayer_"
  Data.s "_Audio\_Player|Soundbase_"
  Data.s "_Audio\_Player|XMPlay_"
  Data.s "_Audio\_Radio|ICY_Radio_"
  Data.s "_Audio\_Radio|RadioSure_"
  Data.s "_Audio\_Radio|Screamer_"
  Data.s "_Audio\_Ripper|BonkEnc_"
  Data.s "_Audio\_Ripper|Freac_"
  Data.s "_Audio\_Tagger|Mp3tag_"
  Data.s "_Audio\_Tagger|TagScanner_"
  Data.s "_Audio\_Text_To_Speech|Balabolka_"
  Data.s "_Audio\_Text_To_Speech|DSpeech_"
  Data.s "_Audio\_Tools|Audio_Identifier_"
  Data.s "_Audio\_Tools|Tunatic_"
  Data.s "_Cd and dvd\_Burning_Tools|Amok_CD-DVD_Burning_"
  Data.s "_Cd and dvd\_Burning_Tools|CDBurnerXP_"
  Data.s "_Cd and dvd\_Burning_Tools|ImgBurn_"
  Data.s "_Cd and dvd\_Burning_Tools|InfraRecorder_"
  Data.s "_Cd and dvd\_Cover_Printer|UnderCoverXP_"
  Data.s "_Cd and dvd\_Image_Tools|AnyToISO_Converter_"
  Data.s "_Cd and dvd\_Image_Tools|Folder2Iso_"
  Data.s "_Cd and dvd\_Image_Tools|LCISOCreator_"
  Data.s "_Cd and dvd\_Image_Tools|Virtual_CDRom_Control_Panel_"
  Data.s "_Education\_Astronomy|Celestia_"
  Data.s "_Education\_Astronomy|Stellarium_"
  Data.s "_Education\_Geography|Marble_"
  Data.s "_Education\_Typing|RapidTyping_"
  Data.s "_Education\_Drawing|TuxPaint_"
  Data.s "_Education\_Children|Childsplay_"
  Data.s "_Education\_Children|TuxMath_"
  Data.s "_Education\_Music|TuxGuitar_"
  Data.s "_File manager\_Backup|Abakt_"
  Data.s "_File manager\_Backup|USB_Image_Tool_"
  Data.s "_File manager\_Cataloguer|CdCat_"
  Data.s "_File manager\_Comparison|KDiff3_"
  Data.s "_File manager\_Comparison|WinMerge_"
  Data.s "_File manager\_Compression|7-Zip_"
  Data.s "_File manager\_Compression|IZArc2Go_"
  Data.s "_File manager\_Compression|PeaZip_"
  Data.s "_File manager\_Compression|Universal_Extractor_"
  Data.s "_File manager\_Copy|TeraCopy_"
  Data.s "_File manager\_Defragmenter|Defraggler_"
  Data.s "_File manager\_Defragmenter|Disk_Defrag_"
  Data.s "_File manager\_Defragmenter|UltraDefrag_"
  Data.s "_File manager\_Directory_Lister|DirHTML_"
  Data.s "_File manager\_Disk_Space_Tool|FilePro_"
  Data.s "_File manager\_Disk_Space_Tool|Folder_Size_"
  Data.s "_File manager\_Disk_Space_Tool|Windirstat_"
  Data.s "_File manager\_Duplicate_Killer|DupKiller_"
  Data.s "_File manager\_Manager|Free_Commander_"
  Data.s "_File manager\_Manager|Q-Dir_"
  Data.s "_File manager\_Recovery|DiskDigger_"
  Data.s "_File manager\_Recovery|Free_Data_Recovery_Software_"
  Data.s "_File manager\_Recovery|Recuva_"
  Data.s "_File manager\_Recovery|Roadkil's_Unstoppable_Copier_"
  Data.s "_File manager\_Renamer|Ant_Renamer_"
  Data.s "_File manager\_Renamer|Bulk_Rename_Utility_"
  Data.s "_File manager\_Renamer|ReNamer_"
  Data.s "_File manager\_Search|Everything_"
  Data.s "_File manager\_Search|SearchMyFiles_"
  Data.s "_File manager\_Splitter|GSplit_"
  Data.s "_File manager\_Splitter|YoyoCut_"
  Data.s "_File manager\_Synchronization|DSynchronize_"
  Data.s "_File manager\_Synchronization|FreeFileSync_"
  Data.s "_File manager\_Tools|NewFileTime_"
  Data.s "_File manager\_Universal_Viewer|Universal_Viewer_"
  Data.s "_Game\_Action|Neverball_"
  Data.s "_Game\_Action|Trackballs_"
  Data.s "_Game\_FPS|AssaultCube_"
  Data.s "_Game\_Card|PokerTH_"
  Data.s "_Game\_Puzzle|Jooleem_"
  Data.s "_Game\_Puzzle|Lines95_"
  Data.s "_Game\_Puzzle|Pathological_"
  Data.s "_Game\_Puzzle|Simple_Sudoku_"
  Data.s "_Game\_Puzzle|USB_Sudoku_"
  Data.s "_Game\_Racing|SuperTuxKart_"
  Data.s "_Game\_Reflexion|Yea_Chess_"
  Data.s "_Game\_Reflexion|Lucas_Chess_"
  Data.s "_Game\_Reflexion|4st_Attack_"
  Data.s "_Game\_Reflexion|AlphaChess_"
  Data.s "_Game\_Reflexion|pouetChess_"
  Data.s "_Game\_Strategy|Bombermaaan_"
  Data.s "_Graphics\_3D|Anim8or_"
  Data.s "_Graphics\_3D|Blender_"
  Data.s "_Graphics\_Colour_Picker|Color_Mania_"
  Data.s "_Graphics\_Colour_Picker|ColorPic_"
  Data.s "_Graphics\_Editor|GIMP_"
  Data.s "_Graphics\_Editor|Inkscape_"
  Data.s "_Graphics\_Editor|MyPaint_"
  Data.s "_Graphics\_Editor|Paint.NET_"
  Data.s "_Graphics\_Editor|Photo_Filtre_"
  Data.s "_Graphics\_Effect_And_Filter|FotoSketcher_"
  Data.s "_Graphics\_Icon_Editor|Greenfish_Icon_Editor_Pro_"
  Data.s "_Graphics\_Icon_Editor|IcoFX_"
  Data.s "_Graphics\_Screen_Capture|FastStone_Capture_"
  Data.s "_Graphics\_Screen_Capture|PicPick_"
  Data.s "_Graphics\_Screen_Capture|Greenshot_"
  Data.s "_Graphics\_Tools|On-Screen_Ruler_"
  Data.s "_Graphics\_Tools|PngOptimizer_"
  Data.s "_Graphics\_Tools|RIOT_"
  Data.s "_Graphics\_Vector_Converter|WinTopo_"
  Data.s "_Graphics\_Viewer|FastStone_Image_Viewer_"
  Data.s "_Graphics\_Viewer|IrfanView_"
  Data.s "_Graphics\_Viewer|XnView_"
  Data.s "_Internet\_Bookmark_Manager|Transmute_"
  Data.s "_Internet\_Browser|Google_Chrome_"
  Data.s "_Internet\_Browser|Chromium_"
  Data.s "_Internet\_Browser|Firefox_"
  Data.s "_Internet\_Browser|Opera_"
  Data.s "_Internet\_Browser|QtWeb_"
  Data.s "_Internet\_Download|eMule_"
  Data.s "_Internet\_Download|Free_Download_Manager_"
  Data.s "_Internet\_Download|uTorrent_"
  Data.s "_Internet\_Email|POP_Peeper_"
  Data.s "_Internet\_Email|PopTray_"
  Data.s "_Internet\_Email|Thunderbird_"
  Data.s "_Internet\_Ftp|FileZilla_"
  Data.s "_Internet\_Instant_Messenger|aMSN_"
  Data.s "_Internet\_Instant_Messenger|Miranda_IM_"
  Data.s "_Internet\_Instant_Messenger|Pidgin_"
  Data.s "_Internet\_Internet_Relay_Chat|MegaIRC_"
  Data.s "_Internet\_Rss_Reader|GreatNews_"
  Data.s "_Internet\_Website_Authoring|iWebAlbum_"
  Data.s "_Internet\_Website_Authoring|KompoZer_"
  Data.s "_Internet\_Website_Authoring|MobaPhoto_"
  Data.s "_Internet\_Webste_Copier|HTTrack_"
  Data.s "_Networking - server\_Bandwidth_Monitor|NetMeter_"
  Data.s "_Networking - server\_Bandwidth_Monitor|NetWorx_"
  Data.s "_Networking - server\_Configuration|B.I.S.S._Hosts_Manager_"
  Data.s "_Networking - server\_Configuration|PE_Network_Configurator_"
  Data.s "_Networking - server\_Configuration|HostsMan_"
  Data.s "_Networking - server\_Network_Analyser|SmartSniff_"
  Data.s "_Networking - server\_Network_Analyser|Yale_"
  Data.s "_Networking - server\_Remote_Control|TeamViewer_"
  Data.s "_Networking - server\_Remote_Control|UltraVNC_Server_"
  Data.s "_Networking - server\_Remote_Control|UltraVNC_Viewer_"
  Data.s "_Networking - server\_Scanner|SoftPerfect_Network_Scanner_"
  Data.s "_Networking - server\_Scanner|Performance_Pinging_"
  Data.s "_Networking - server\_Server|HFS_"
  Data.s "_Networking - server\_Settings_Manager|Net_Profiles_"
  Data.s "_Networking - server\_Settings_Manager|NetSetMan_"
  Data.s "_Networking - server\_Telnet_Ssh_Client|KiTTY_(PuTTY)_"
  Data.s "_Networking - server\_Telnet_Ssh_Client|TeraTerm_Pro_"
  Data.s "_Networking - server\_Telnet_Ssh_Client|WinSCP_"
  Data.s "_Networking - server\_Tools|CurrPorts_"
  Data.s "_Networking - server\_Tools|DShutdown_"
  Data.s "_Networking - server\_Tools|eToolz_"
  Data.s "_Networking - server\_Tools|IP2_"
  Data.s "_Networking - server\_Tools|IPNetInfo_"
  Data.s "_Networking - server\_Tools|Network_Stuff_"
  Data.s "_Office\_Calculator|ESBCalc_"
  Data.s "_Office\_Calculator|MyCalc2_"
  Data.s "_Office\_Calculator|SpeedCrunch_"
  Data.s "_Office\_Calendar|EssentialPIM_"
  Data.s "_Office\_Calendar|Rainlendar_Lite_"
  Data.s "_Office\_Calendar|Sunbird_"
  Data.s "_Office\_Chrono|Pc_Chrono_"
  Data.s "_Office\_Desktop_Tools\_Application_Launcher|Executor_"
  Data.s "_Office\_Desktop_Tools\_Application_Launcher|RocketDock_"
  Data.s "_Office\_Desktop_Tools\_Automation|AutoHotkey_"
  Data.s "_Office\_Desktop_Tools\_Automation|Clavier+_"
  Data.s "_Office\_Desktop_Tools\_Clipboard_Manager|Clipboardic_"
  Data.s "_Office\_Desktop_Tools\_Clipboard_Manager|Ditto_"
  Data.s "_Office\_Desktop_Tools\_Clock|ClocX_"
  Data.s "_Office\_Desktop_Tools\_Clock|TimeSync_"
  Data.s "_Office\_Desktop_Tools\_Customisation|AquaSnap_"
  Data.s "_Office\_Desktop_Tools\_Customisation|Shock_Caption_"
  Data.s "_Office\_Desktop_Tools\_Notes|PNotes_"
  Data.s "_Office\_Desktop_Tools\_Notes|Stickies_"
  Data.s "_Office\_Desktop_Tools\_Keyboard_And_Mouse|Click-N-Type_"
  Data.s "_Office\_Desktop_Tools\_Save_Desktop_Icon|DesktopOK_"
  Data.s "_Office\_Desktop_Tools\_Save_Desktop_Icon|Shock_Desktop_"
  Data.s "_Office\_Desktop_Tools\_Virtual_Desktop|VirtuaWin_"
  Data.s "_Office\_Desktop_Tools\_Zoom|Virtual_Magnifying_Glass_"
  Data.s "_Office\_Desktop_Tools\_Zoom|ZoomIt_"
  Data.s "_Office\_Diagram_Editor|Dia_"
  Data.s "_Office\_Diagram_Editor|Diagram_Designer_"
  Data.s "_Office\_Finance_Manager|Money_Manager_"
  Data.s "_Office\_Finance_Manager|viCompte_"
  Data.s "_Office\_Font_Manager|AMP_Font_Viewer_"
  Data.s "_Office\_Font_Manager|FontList_"
  Data.s "_Office\_Font_Manager|NexusFont_"
  Data.s "_Office\_Note_Manager|TreeDBNotes_"
  Data.s "_Office\_Office_Suite|AbiWord_"
  Data.s "_Office\_Office_Suite|LibreOffice_"
  Data.s "_Office\_Office_Suite|OpenOffice.org_"
  Data.s "_Office\_Office_Suite|Scribus_"
  Data.s "_Office\_Pdf|Foxit_Reader_"
  Data.s "_Office\_Pdf|PDFTK_Builder_"
  Data.s "_Office\_Pdf|PDF-XChange_Viewer_"
  Data.s "_Office\_Pdf|SumatraPDF_"
  Data.s "_Office\_Presentation|Pointofix_"
  Data.s "_Office\_Task_Manager|Task_Coach_"
  Data.s "_Office\_Text_Editor|AkelPad_"
  Data.s "_Office\_Text_Editor|Notepad++_"
  Data.s "_Office\_Text_Editor|PSPad_"
  Data.s "_Office\_Text_Editor|RJ_TextEd_"
  Data.s "_Office\_Tutorial_Creator|vTute_Recorder_"
  Data.s "_Office\_Tutorial_Creator|Wink_"
  Data.s "_Office\_Unit_Converter|Converber_"
  Data.s "_Office\_Unit_Converter|ESBUnitConv_"
  Data.s "_Office\_Universal_Viewer|STDU_Viewer_"
  Data.s "_Office\_Universal_Viewer|Evince_"
  Data.s "_Platform|LiberKey_"
  Data.s "_Platform|LiberKey_Platform_"
  Data.s "_Removed|ThrottleWatch_"
  Data.s "_Removed|Visual_Tooltip_"
  Data.s "_Removed|WinFlip_"
  Data.s "_Security\_AntiVirus_And_Spyware|ClamWin_"
  Data.s "_Security\_AntiVirus_And_Spyware|Runscanner_"
  Data.s "_Security\_AntiVirus_And_Spyware|SpyDLLRemover_"
  Data.s "_Security\_Encryption|DCU_"
  Data.s "_Security\_Encryption|Omziff_"
  Data.s "_Security\_Encryption|TrueCrypt_"
  Data.s "_Security\_Integrity_Checker|HashCalc_"
  Data.s "_Security\_Integrity_Checker|HashMyFiles_"
  Data.s "_Security\_Password_Manager|KeePass_Classic_Edition_"
  Data.s "_Security\_Password_Manager|KeePass_Professional_Edition_"
  Data.s "_Security\_Password_Manager|Password_Generator_"
  Data.s "_Security\_Privacy_Tool|XP-AntiSpy_"
  Data.s "_Security\_Secure_Deletion|UltraShredder_"
  Data.s "_Security\_Secure_Deletion|WipeDisk_"
  Data.s "_Security\_Secure_Deletion|WipeFile_"
  Data.s "_Security\_Tools|USB_WriteProtector_"
  Data.s "_System utilities\_Benchmark\_HardDisk|CrystalDiskMark_"
  Data.s "_System utilities\_Benchmark\_HardDisk|HD_Speed_"
  Data.s "_System utilities\_Benchmark\_Universal|CrystalMark_"
  Data.s "_System utilities\_Cleaner_Uninstaller|CCleaner_"
  Data.s "_System utilities\_Cleaner_Uninstaller|CleanAfterMe_"
  Data.s "_System utilities\_Cleaner_Uninstaller|Driver_Sweeper_"
  Data.s "_System utilities\_Cleaner_Uninstaller|FCleaner_"
  Data.s "_System utilities\_Cleaner_Uninstaller|FileASSASSIN_"
  Data.s "_System utilities\_Cleaner_Uninstaller|Glary_Utilities_"
  Data.s "_System utilities\_Cleaner_Uninstaller|JavaRa_"
  Data.s "_System utilities\_Cleaner_Uninstaller|MUICacheView_"
  Data.s "_System utilities\_Cleaner_Uninstaller|MyUninstaller_"
  Data.s "_System utilities\_Cleaner_Uninstaller|Remove_Empty_Directories_"
  Data.s "_System utilities\_Cleaner_Uninstaller|Revo_Uninstaller_"
  Data.s "_System utilities\_Cleaner_Uninstaller|Unlocker_"
  Data.s "_System utilities\_Cleaner_Uninstaller|Wise_Disk_Cleaner_"
  Data.s "_System utilities\_Emulator|MobaLiveCD_"
  Data.s "_System utilities\_Hex_Editor|HxD_"
  Data.s "_System utilities\_Information\_File_Monitoring|OpenedFilesView_"
  Data.s "_System utilities\_Information\_Hardware_Monitoring|HWMonitor_"
  Data.s "_System utilities\_Information\_Inventory|HWINFO32_"
  Data.s "_System utilities\_Information\_Inventory|PC_Wizard_"
  Data.s "_System utilities\_Information\_Inventory|SIW_"
  Data.s "_System utilities\_Information\_Inventory|Speccy_"
  Data.s "_System utilities\_Information\_Inventory|System_Explorer_"
  Data.s "_System utilities\_Information\_Inventory|System_Spec_"
  Data.s "_System utilities\_Information\_Inventory|WinAudit_"
  Data.s "_System utilities\_Information\_Inventory|Glint_"
  Data.s "_System utilities\_Information\_Process|Bill2's_Process_Manager_"
  Data.s "_System utilities\_Information\_Process|DTaskManager_"
  Data.s "_System utilities\_Information\_Process|Process_Explorer_"
  Data.s "_System utilities\_Information\_Process|Process_Hacker_"
  Data.s "_System utilities\_Information\_Processor|CPU-Z_"
  Data.s "_System utilities\_Information\_Processor|CrystalCPUID_"
  Data.s "_System utilities\_Information\_Processor|Slow_"
  Data.s "_System utilities\_Information\_Service|ServiWin_"
  Data.s "_System utilities\_Information\_Startup_Manager|Autoruns_"
  Data.s "_System utilities\_Information\_Startup_Manager|Startup_Control_Panel_"
  Data.s "_System utilities\_Information\_Usb_Device|USBDeview_"
  Data.s "_System utilities\_Information\_Video_Card|GPU_Caps_Viewer_"
  Data.s "_System utilities\_Information\_Video_Card|GPU-Z_"
  Data.s "_System utilities\_Registry\_Backup|Erunt_"
  Data.s "_System utilities\_Registry\_Comparison|Regshot_"
  Data.s "_System utilities\_Registry\_Compression|NTREGOPT_"
  Data.s "_System utilities\_Registry\_Compression|Quicksys_RegDefrag_"
  Data.s "_System utilities\_Registry\_Monitoring|Process_Monitor_"
  Data.s "_System utilities\_Registry\_Monitoring|RegFromApp_"
  Data.s "_System utilities\_Registry\_Repair|Free_Window_Registry_Repair_"
  Data.s "_System utilities\_Registry\_Repair|Wise_Registry_Cleaner_"
  Data.s "_System utilities\_Registry\_Search|RegScanner_"
  Data.s "_System utilities\_Repair|Partition_Find_and_Mount_"
  Data.s "_System utilities\_Tests\_Burning_Test|HeavyLoad_"
  Data.s "_System utilities\_Tests\_Burning_Test|OCCT_"
  Data.s "_System utilities\_Tests\_Hard_Disk|CrystalDiskInfo_"
  Data.s "_System utilities\_Tests\_Hard_Disk|HD_Tune_"
  Data.s "_System utilities\_Tests\_Monitor|CheckeMON_"
  Data.s "_System utilities\_Tests\_Monitor|Eizo_Monitortest_"
  Data.s "_System utilities\_Tests\_Ram|MemTest_"
  Data.s "_System utilities\_Tools|Autoplay_Repair_"
  Data.s "_System utilities\_Tools|BlueScreenView_"
  Data.s "_System utilities\_Tools|ColorConsole_"
  Data.s "_System utilities\_Tools|Drive_Manager_"
  Data.s "_System utilities\_Tools|Fast_Explorer_"
  Data.s "_System utilities\_Tools|Fat32Formatter_"
  Data.s "_System utilities\_Tools|FileTypesMan_"
  Data.s "_System utilities\_Tools|Path_Editor_"
  Data.s "_System utilities\_Tools|RAMRush_"
  Data.s "_System utilities\_Tools|Rapid_Environment_Editor_"
  Data.s "_System utilities\_Tools|RegDllView_"
  Data.s "_System utilities\_Tools|ResourcesExtract_"
  Data.s "_System utilities\_Tools|ShellExView_"
  Data.s "_System utilities\_Tools|SysExporter_"
  Data.s "_System utilities\_Tools|USB_Disk_Ejector_"
  Data.s "_System utilities\_Tools|PeStudio_"
  Data.s "_System utilities\_Tweaker|Tweak_UI_"
  Data.s "_System utilities\_Tweaker|XdN_Tweaker_"
  Data.s "_System utilities\_Tweaker|XP-Config_"
  Data.s "_System utilities\_Update_Checker|Filehippo_Update_Checker_"
  Data.s "_Video\_Authoring|DVDStyler_"
  Data.s "_Video\_Capture|VDownloader_"
  Data.s "_Video\_Capture|WebVideoCap_"
  Data.s "_Video\_Capture|xVideoServiceThief_"
  Data.s "_Video\_Cataloguer|Ant_Movie_Catalog_"
  Data.s "_Video\_Cataloguer|Filmotech_"
  Data.s "_Video\_Converter|Pocket_Divx_Encoder_"
  Data.s "_Video\_Editor|Avidemux_"
  Data.s "_Video\_Editor|VirtualDub_"
  Data.s "_Video\_Player|Media_Player_Classic_"
  Data.s "_Video\_Player|MPC_HomeCinema_"
  Data.s "_Video\_Player|VLC_media_player_"
  Data.s "_Video\_Player|Wimpy_FLV_Player_"
  Data.s "_Video\_Repair|DivFix++_"
  Data.s "_Video\_Tools|Aspect_"
  Data.s "_Video\_Tools|Codec_Tweak_Tool_"
  Data.s "_Video\_Tools|K-Lite_Codec_Tweak_Tool_"
  Data.s "_Video\_Tools|Filmerit_"
  Data.s "_Video\_Tools|GSpot_"
  Data.s "_Video\_Tools|MediaInfo_"
  Data.s "_Video\_Tools|VideoCalc_"
  Data.s "_END_"
  _PTK_PortableAppsSort_Data:
  Data.s "_Accessibility|On-ScreenKeyboardPortable_"
  Data.s "_Accessibility|VirtualMagnifyingGlassPortable_"
  Data.s "_Development|AkelPadPortable_"
  Data.s "_Development|DatabaseBrowserPortable_"
  Data.s "_Development|GeanyPortable_"
  Data.s "_Development|gVimPortable_"
  Data.s "_Development|NotepadPlusPlusPortable_"
  Data.s "_Development|Notepad2Portable_"
  Data.s "_Development|NSISPortableANSI_"
  Data.s "_Development|NSISPortable_"
  Data.s "_Development|PortableApps.comInstaller_"
  Data.s "_Development|PortableApps.comLauncher_"
  Data.s "_Development|SQLiteDatabaseBrowserPortable_"
  Data.s "_Development|Notepad2-modPortable_"
  Data.s "_Development|FrhedPortable_"
  Data.s "_Education|BPBiblePortable_"
  Data.s "_Education|CelestiaPortable_"
  Data.s "_Education|FreeMatPortable_"
  Data.s "_Education|GoldenDictPortable_"
  Data.s "_Education|GrampsPortable_"
  Data.s "_Education|MarblePortable_"
  Data.s "_Education|StellariumPortable_"
  Data.s "_Education|TypeFasterPortable_"
  Data.s "_Education|MnemosynePortable_"
  Data.s "_Education|Tipp10Portable_"
  Data.s "_Games|ArmagetronAdvancedPortable_"
  Data.s "_Games|AssaultCubePortable_"
  Data.s "_Games|AtomicTanksPortable_"
  Data.s "_Games|WesnothPortable_"
  Data.s "_Games|BigSolitairesPortable_"
  Data.s "_Games|BrutalChessPortable_"
  Data.s "_Games|CanabaltPortable_"
  Data.s "_Games|CubePortable_"
  Data.s "_Games|DOSBoxPortable_"
  Data.s "_Games|FreecivPortable_"
  Data.s "_Games|FretsOnFirePortable_"
  Data.s "_Games|GetSudokuPortable_"
  Data.s "_Games|HedgewarsPortable_"
  Data.s "_Games|IceBreakerPortable_"
  Data.s "_Games|JooleemPortable_"
  Data.s "_Games|LBreakout2Portable_"
  Data.s "_Games|LMarblesPortable_"
  Data.s "_Games|Mines-PerfectPortable_"
  Data.s "_Games|Monster2Portable_"
  Data.s "_Games|NetHackPortable_"
  Data.s "_Games|NeverballPortable_"
  Data.s "_Games|OpenTTDPortable_"
  Data.s "_Games|PathologicalPortable_"
  Data.s "_Games|PokerTHPortable_"
  Data.s "_Games|PuzzleCollectionPortable_"
  Data.s "_Games|RocksnDiamondsPortable_"
  Data.s "_Games|SauerbratenPortable_"
  Data.s "_Games|SudokuPortable_"
  Data.s "_Games|SuperTuxKartPortable_"
  Data.s "_Games|T-3Portable_"
  Data.s "_Games|TheManaWorldPortable_"
  Data.s "_Games|Tick5Portable_"
  Data.s "_Games|TileWorldPortable_"
  Data.s "_Games|TwinDistressPortable_"
  Data.s "_Games|Warzone2100Portable_"
  Data.s "_Games|WAtomicPortable_"
  Data.s "_Games|WinBoardPortable_"
  Data.s "_Games|X-MotoPortable_"
  Data.s "_Games|ZazPortable_"
  Data.s "_Games|ChromiumBSUPortable_"
  Data.s "_Games|KoboDeluxePortable_"
  Data.s "_Games|Hex-A-HopPortable_"
  Data.s "_Games|netPanzerPortable_"
  Data.s "_Games|QuickBridgePortable_"
  Data.s "_Games|QuickCribbagePortable_"
  Data.s "_Games|QuickPokerPortable_"
  Data.s "_Games|QuickSolitairePortable_"
  Data.s "_Games|WarMUXPortable_"
  Data.s "_Games|Scorched3DPortable_"
  Data.s "_Graphics And Pictures|AniFXPortable_"
  Data.s "_Graphics And Pictures|BlenderPortable_"
  Data.s "_Graphics And Pictures|CornicePortable_"
  Data.s "_Graphics And Pictures|DiaPortable_"
  Data.s "_Graphics And Pictures|FotografixPortable_"
  Data.s "_Graphics And Pictures|FyrePortable_"
  Data.s "_Graphics And Pictures|GIMPPortable_"
  Data.s "_Graphics And Pictures|IcoFXPortable_"
  Data.s "_Graphics And Pictures|InkscapePortable_"
  Data.s "_Graphics And Pictures|IrfanViewPortable_"
  Data.s "_Graphics And Pictures|JPEGViewPortable_"
  Data.s "_Graphics And Pictures|K-3DPortable_"
  Data.s "_Graphics And Pictures|PhotoFiltrePortable_"
  Data.s "_Graphics And Pictures|XnViewPortable_"
  Data.s "_Internet|aMSNPortable_"
  Data.s "_Internet|DamnVidPortable_"
  Data.s "_Internet|FeedNotifierPortable_"
  Data.s "_Internet|FileZillaPortable_"
  Data.s "_Internet|GoogleChromePortableBeta_"
  Data.s "_Internet|GoogleChromePortableDev_"
  Data.s "_Internet|GoogleChromePortable_"
  Data.s "_Internet|google_chrome_portable_"
  Data.s "_Internet|JuicePortable_"
  Data.s "_Internet|KVIrcPortable_"
  Data.s "_Internet|MaxthonPortable_"
  Data.s "_Internet|MirandaPortable_"
  Data.s "_Internet|FirefoxPortableTest_"
  Data.s "_Internet|FirefoxPortable_"
  Data.s "_Internet|ThunderbirdPortable_"
  Data.s "_Internet|OperaPortable_"
  Data.s "_Internet|PChatPortable_"
  Data.s "_Internet|PidginPortable_"
  Data.s "_Internet|PrivateBrowsingByPortableApps_"
  Data.s "_Internet|PuTTY_Portable_"
  Data.s "_Internet|qBittorrentPortable_"
  Data.s "_Internet|SeaMonkeyPortable_"
  Data.s "_Internet|SkypePortable_"
  Data.s "_Internet|uTorrentPortable_"
  Data.s "_Internet|WinSCPPortable_"
  Data.s "_Internet|vWinWGet_Portable_"
  Data.s "_Internet|IronPortable_"
  Data.s "_Internet|JavaPortableLauncher_"
  Data.s "_Internet|Java_Portable_6_Update_"
  Data.s "_Internet|KompoZerPortable_"
  Data.s "_Internet|gPodderPortable_"
  Data.s "_Internet|PopManPortable_"
  Data.s "_Internet|FirefoxPortableLegacy36_"
  Data.s "_Internet|QuteComPortable_"
  Data.s "_Internet|ThunderbirdPortableTest_"
  Data.s "_Internet|WinWGet_Portable_"
  Data.s "_Internet|wxDownloadFastPortable_"
  Data.s "_Music And Video|AudacityPortable_"
  Data.s "_Music And Video|CDExPortable_"
  Data.s "_Music And Video|cdrtfePortable_"
  Data.s "_Music And Video|CoolPlayerPlusPortable_"
  Data.s "_Music And Video|DVDStylerPortable_"
  Data.s "_Music And Video|freacPortable_"
  Data.s "_Music And Video|InfraRecorderPortable_"
  Data.s "_Music And Video|InfraRecorder_Portable_MP3_Plugin_"
  Data.s "_Music And Video|LAME_MP3_Encoder_for_freac_Portable_"
  Data.s "_Music And Video|PaulStretchPortable_"
  Data.s "_Music And Video|SMPlayerPortable_"
  Data.s "_Music And Video|SongbirdPortable_"
  Data.s "_Music And Video|VirtualDubPortable_"
  Data.s "_Music And Video|VLCPortable_"
  Data.s "_Music And Video|XMPlayPortable_"
  Data.s "_Music And Video|MP3GainPortable_"
  Data.s "_Music And Video|MuseScorePortable_"
  Data.s "_Office|AbiWordPortable_"
  Data.s "_Office|EvincePortable_"
  Data.s "_Office|FinanceExplorerPortable_"
  Data.s "_Office|FocusWriterPortable_"
  Data.s "_Office|FoxitReaderPortable_"
  Data.s "_Office|GnuCashPortable_"
  Data.s "_Office|GnumericPortable_"
  Data.s "_Office|LibreOfficePortable_"
  Data.s "_Office|MoneyManagerExPortable_"
  Data.s "_Office|SunbirdPortable_"
  Data.s "_Office|OpenOfficePortable_"
  Data.s "_Office|PDFTKBuilderPortable_"
  Data.s "_Office|PNotesPortable_"
  Data.s "_Office|RedNotebookPortable_"
  Data.s "_Office|SpeedCrunchPortable_"
  Data.s "_Office|StickiesPortable_"
  Data.s "_Office|SumatraPDFPortable_"
  Data.s "_Office|TaskCoachPortable_"
  Data.s "_Office|TheGuidePortable_"
  Data.s "_Office|ToDoListPortable_"
  Data.s "_Office|WinDjViewPortable_"
  Data.s "_Security|ClamWinPortable_"
  Data.s "_Security|EraserDropPortable_"
  Data.s "_Security|EraserPortable_"
  Data.s "_Security|KeePassPortable_"
  Data.s "_Security|SpybotPortable_"
  Data.s "_Security|SpyDLLRemover_"
  Data.s "_Utilities|2XClient_"
  Data.s "_Utilities|7-ZipPortable_"
  Data.s "_Utilities|AntRenamerPortable_"
  Data.s "_Utilities|AquaSnapPortable_"
  Data.s "_Utilities|BleachBitPortable_"
  Data.s "_Utilities|CamStudioPortable_"
  Data.s "_Utilities|CommandPromptPortable_"
  Data.s "_Utilities|ConsolePortable_"
  Data.s "_Utilities|ConverberPortable_"
  Data.s "_Utilities|ConvertAllPortable_"
  Data.s "_Utilities|CookTimerPortable_"
  Data.s "_Utilities|CrystalDiskInfoPortable_"
  Data.s "_Utilities|CubicExplorerPortable_"
  Data.s "_Utilities|DaphnePortable_"
  Data.s "_Utilities|DiskCleanerPortable_"
  Data.s "_Utilities|DSynchronizePortable_"
  Data.s "_Utilities|FreeCommanderPortable_"
  Data.s "_Utilities|FreeUPXPortable_"
  Data.s "_Utilities|IObitUninstallerPortable_"
  Data.s "_Utilities|JkDefrag_Portable_"
  Data.s "_Utilities|jPortable_"
  Data.s "_Utilities|LightscreenPortable_"
  Data.s "_Utilities|PeaZipPortable_"
  Data.s "_Utilities|PortableApps.comAppCompactor_"
  Data.s "_Utilities|RegshotPortable_"
  Data.s "_Utilities|RevoUninstallerPortable_"
  Data.s "_Utilities|SmartDefragPortable_"
  Data.s "_Utilities|SynkronPortable_"
  Data.s "_Utilities|SystemExplorerPortable_"
  Data.s "_Utilities|TeamViewerPortable_"
  Data.s "_Utilities|TexterPortable_"
  Data.s "_Utilities|Toucan_"
  Data.s "_Utilities|UUID-GUIDGeneratorPortable_"
  Data.s "_Utilities|VirtualVolumesViewPortable_"
  Data.s "_Utilities|VirtuaWinPortable_"
  Data.s "_Utilities|WinDirStatPortable_"
  Data.s "_Utilities|winMd5SumPortable_"
  Data.s "_Utilities|WinPenguinsPortable_"
  Data.s "_Utilities|WinMergePortable_"
  Data.s "_Utilities|WinMTRPortable_"
  Data.s "_Utilities|WorkravePortable_"
  Data.s "_Utilities|XenonPortable_"
  Data.s "_Utilities|XNResourceEditorPortable_"
  Data.s "_Utilities|ChecksumControlPortable_"
  Data.s "_Utilities|CrystalDiskMarkPortable_"
  Data.s "_Utilities|DiffpdfPortable_"
  Data.s "_Utilities|DittoPortable_"
  Data.s "_Utilities|DM2Portable_"
  Data.s "_Utilities|DontPanicPortable_"
  Data.s "_Utilities|DShutdownPortable_"
  Data.s "_Utilities|DTaskManagerPortable_"
  Data.s "_Utilities|ExplorerPlusPlusPortable_"
  Data.s "_Utilities|ListaryPortable_"
  Data.s "_Utilities|SIWPortable_"
  Data.s "_Utilities|TinyTaskPortable_"
  Data.s "_Utilities|WindowsErrorLookupToolPortable_"
  Data.s "_Utilities|ZintPortable_"
  Data.s "_END_"
EndDataSection

Declare.s GetIniVal(IniSection.s, IniKey.s)                                             ; API procedure to replace Mr Skunk's INI file reading routine
Declare   SetIniVal(IniSection.s, IniKey.s, IniValue.s)                                 ; PB procedure to shorten INI file handling
Declare   CheckDumpMode()                                                               ; Check whether we want to dump a report of the leftover files or not
Declare   ChooseIndex()                                                                 ; Choose which directories type to sort
Declare   DumpLeftOvers()                                                               ; Dump any unsorted files to a log file for adding to the internal list
Declare   GetSourceFiles()                                                              ; Universal, recursive search engine
Declare   LastLine(Gadget, LineNumber)                                                  ; Go to the last line of a ListIconGadget
Declare.i MakeSureDirectoryPathExists(Directory.s)                                      ; Need a unicode aware version of the API directory creator
Declare   SortFiles()                                                                   ; Go and sort the retrieved LiberKey data files
Declare   GetPortableAppsTargetPath()                                                   ; Get the source path for the PortableApps files to sort to
Declare   GetPortableAppsSourcePath()                                                   ; Get the source path for the PortableApps files to gather from
Declare   GetLiberKeyTargetPath()                                                       ; Get the target path for the LiberKey files to sort to
Declare   GetLiberKeySourcePath()                                                       ; Get the source path for the LiberKey files to gather from
Declare   CreatePreferencesFile()                                                       ; Create a brand new INI file in the program directory if the default one is missing, with default values.
Declare   ReadPreferencesFile()                                                         ; Read the system preferences file or create it if missing
Declare   SavePreferencesFile()                                                         ; Read the system preferences file or create it if missing

Re: LiberKey offline files sorter

Posted: Wed Dec 07, 2011 10:16 am
by Fangbeast
Project updated to include PortableApps update files as well. All the apps are in a DataSection, all other settings in an INI files.

Don't have time for much explanation, have health issues. Part 2 of 2

Code: Select all

; API procedure to replace Mr Skunk's INI file reading routine

Procedure.s GetIniVal(IniSection.s, IniKey.s)
  ; Open the Ini file for reading
  If OpenPreferences(Program\IniFile)
    ; Go to the right group
    PreferenceGroup(IniSection.s)
    ; Read a value from the ini file
    IniData.s = ReadPreferenceString(IniKey.s, "")
    ; Close the INI file, finished
    ClosePreferences()
    ; Return the data to the calling line
    ProcedureReturn IniData.s
  Else
    Debug "Cannot open " + Program\IniFile + "!!!"
  EndIf
EndProcedure

; PB procedure to shorten INI file handling

Procedure SetIniVal(IniSection.s, IniKey.s, IniValue.s)
  If OpenPreferences(Program\IniFile)                                                   ; Open the Ini file for reading
    PreferenceGroup(IniSection.s)                                                       ; Go to the right group
    WritePreferenceString(IniKey.s, IniValue.s)                                         ; Write the value to the INI file
    ClosePreferences()                                                                  ; Close the INI file, finished
  Else
    Debug "Cannot open " + Program\IniFile + "!!!"
  EndIf
EndProcedure

; Check whether we want to dump a report of the leftover files or not

Procedure CheckDumpMode()
  DumpState.i = GetGadgetState(#Gadget_PortaSort_cbDumpLeftovers)
  If DumpState.i = 0
    Program\DumpLeftOvers = "No"
  ElseIf DumpState.i = 1
    Program\DumpLeftOvers = "Yes"
  EndIf
EndProcedure

; Choose which directories type to sort

Procedure ChooseIndex()
  If ListSize(Index())
    ClearList(Index())
  EndIf
  PortaType.s = GetGadgetText(#Gadget_PortaSort_SelectIndex)
  Program\LastIndex = PortaType.s
  Select PortaType.s
    Case  "LiberKey"
      Restore _PTK_LiberKeySort_Data
      While TempString.s <> "_END_"
        Read.s TempString.s
        If TempString.s <> "_END_"
          AddElement(Index())
          Index()\Directory    = StringField(TempString.s, 1, "|")
          Index()\BaseFilename = StringField(TempString.s, 2, "|")
        EndIf
      Wend
      AddGadgetItem(#Gadget_PortaSort_errors, -1, "Index load" + Chr(10) + "<°)))o><²³  LiberKey file sort index list loaded")
      TempString.s = "<><>"
      SetGadgetText(#Gadget_PortaSort_SourceDir,              Program\LiberkeySourcePath)
      SetGadgetText(#Gadget_PortaSort_TargetDir,              Program\LiberKeyTargetPath)
      SetGadgetText(#Gadget_PortaSort_LiberkeySourceDir,      Program\LiberkeySourcePath)
      SetGadgetText(#Gadget_PortaSort_LiberkeyTargetDir,      Program\LiberKeyTargetPath)
      MakeSureDirectoryPathExists(Program\LiberKeyTargetPath)
      GetSourceFiles()
    Case  "PortableApps"
      Restore _PTK_PortableAppsSort_Data
      While TempString.s <> "_END_"
        Read.s TempString.s
        If TempString.s <> "_END_"
          AddElement(Index())
          Index()\Directory    = StringField(TempString.s, 1, "|")
          Index()\BaseFilename = StringField(TempString.s, 2, "|")
        EndIf
      Wend
      AddGadgetItem(#Gadget_PortaSort_errors, -1, "Index load" + Chr(10) + "<°)))o><²³  PortableApps file sort index list loaded")
      TempString.s = "<><>"
      SetGadgetText(#Gadget_PortaSort_SourceDir,              Program\PortableAppsSourcePath)
      SetGadgetText(#Gadget_PortaSort_TargetDir,              Program\PortableAppsTargetPath)
      SetGadgetText(#Gadget_PortaSort_PortableAppsSourceDir,  Program\PortableAppsSourcePath)
      SetGadgetText(#Gadget_PortaSort_PortableAppsTargetDir,  Program\PortableAppsTargetPath)
      MakeSureDirectoryPathExists(Program\PortableAppsTargetPath)
      GetSourceFiles()
  EndSelect
EndProcedure

; Dump any unsorted files to a log file for adding to the internal list

Procedure DumpLeftOvers()
  NumItems = CountGadgetItems(#Gadget_PortaSort_tosortfrom)
  If NumItems <> 0
    FileId = CreateFile(#PB_Any, Program\LogFile)
    If FileId
      WriteStringN(FileId, "-----------------------------------------------------------------------------------")
      WriteStringN(Fileid, "Start of [" + Program\LastIndex + "] orphan files listing.")
      WriteStringN(FileId, "-----------------------------------------------------------------------------------")
      WriteStringN(FileId, "")
      For LoopItems = 0 To NumItems -1
        WriteStringN(FileId, GetGadgetItemText(#Gadget_PortaSort_tosortfrom, LoopItems))
      Next
      WriteStringN(FileId, "-----------------------------------------------------------------------------------")
      WriteStringN(FileId, "End of [" + Program\LastIndex + "] orphan files listing.")
      WriteStringN(FileId, "-----------------------------------------------------------------------------------")
      WriteStringN(FileId, "")
      CloseFile(FileId)
    EndIf
  EndIf
EndProcedure

; Universal, recursive search engine

Procedure GetSourceFiles()
  If CountGadgetItems(#Gadget_PortaSort_tosortfrom) <> 0
    ClearGadgetItems(#Gadget_PortaSort_tosortfrom)
  EndIf
  If CountGadgetItems(#Gadget_PortaSort_ToSortTo) <> 0
    ClearGadgetItems(#Gadget_PortaSort_ToSortTo)
  EndIf
  SearchDir.s = GetGadgetText(#Gadget_PortaSort_sourcedir)
  If SearchDir.s
    AddGadgetItem(#Gadget_PortaSort_errors, -1, "Fetching files" + Chr(10) + "<°)))o><²³  Retrieving files from " + SearchDir.s)
    SetGadgetText(#Gadget_PortaSort_sourcedir, SearchDir.s)
    ClearList(FoundDirs.s())
    If SearchDir.s <> ""
      If Right(SearchDir.s, 1) = "\"
        SearchDir.s = Left(SearchDir.s, Len(SearchDir.s) - 1)
      EndIf
      AddElement(FoundDirs.s())
      FoundDirs.s() = SearchDir.s
      Index = 0
      Repeat
        SelectElement(FoundDirs.s(), Index)
        Directory = ExamineDirectory(#PB_Any, FoundDirs.s(), "*.*")
        If Directory
          Path.s = FoundDirs.s() + "\"
          While NextDirectoryEntry(Directory)
            Filename.s = DirectoryEntryName(Directory)
            Select DirectoryEntryType(Directory)
              Case 1
                While WindowEvent() : Wend
                LiberCheck.s      = LCase(Right(Filename, 4))
                PortaAppsCheck.s  = LCase(Right(Filename, 8))
                If LiberCheck.s = ".lks" Or PortaAppsCheck.s = ".paf.exe"
                  Counter + 1
                  AddGadgetItem(#Gadget_PortaSort_tosortfrom, -1, FileName.s)
                  SetWindowTitle(#Window_PortaSort, Program\WindowTitle + Str(Counter) + "  " + Program\LastIndex + " Files found")
                  ; Colour alternate lines in grey shades of colour
                  If Program\ColourToggle = 1
                    Program\ColourToggle = 0
                    SetGadgetItemColor(#Gadget_PortaSort_tosortfrom, Counter -1, #PB_Gadget_BackColor, $D4D4D4)
                  ElseIf Program\ColourToggle = 0
                    Program\ColourToggle = 1
                    SetGadgetItemColor(#Gadget_PortaSort_tosortfrom, Counter -1, #PB_Gadget_BackColor, $C1C1C1)
                  EndIf
                EndIf
              Case 2
                Filename.s = DirectoryEntryName(Directory)
                If Filename.s <> ".." And Filename.s <> "."
                  AddElement(FoundDirs())
                  FoundDirs() = Path + Filename.s
                EndIf
            EndSelect
          Wend
          FinishDirectory(Directory)
        EndIf
        Index + 1
      Until Index > ListSize(FoundDirs()) -1
      AddGadgetItem(#Gadget_PortaSort_errors, -1, "Finished fetching" + Chr(10) + "<°)))o><²³  found all files for " + Program\LastIndex)
    EndIf
  Else
    AddGadgetItem(#Gadget_PortaSort_errors, -1, "Source abort" + Chr(10) + "<°)))o><²³  The selected directory to search is empty")
  EndIf
EndProcedure

; Go to the last line of a ListIconGadget

Procedure LastLine(Gadget, LineNumber)
  SendMessage_(GadgetID(Gadget), #LVM_ENSUREVISIBLE, LineNumber, 0) ; Make sure the current line is visible
EndProcedure

; Need a unicode aware version of the API directory creator

Procedure.i MakeSureDirectoryPathExists(Directory.s)
;   Return 1 If success / 0 If fail 
  ResultCode = SHCreateDirectory(#Null, Directory.s)
  If ResultCode = #ERROR_SUCCESS
    ResultCode = 1
  Else
    ResultCode = 0
  EndIf
  ProcedureReturn ResultCode
EndProcedure

; Go and sort the retrieved LiberKey data files

Procedure SortFiles()
  ; Get the currently displayed source directory
  SourceDir.s = GetGadgetText(#Gadget_PortaSort_sourcedir)
  ; Get the currently displayed target directory
  TargetDir.s = GetGadgetText(#Gadget_PortaSort_targetdir)
  ; Check to see if the source directory doesn't equal the target directory!!
  If SourceDir.s <> TargetDir.s
    ; Check to see if there was a target directory specified (Corrupt ini file)
    If TargetDir.s 
      ; Count out how many items are to be sorted
      NumFiles = CountGadgetItems(#Gadget_PortaSort_tosortfrom) - 1
      ; Now iterate through the list and process each name
      For SortLoop = NumFiles To 0 Step -1
        ; Get the curent file name to be processed from the list
        CurrentFile.s = GetGadgetItemText(#Gadget_PortaSort_tosortfrom, SortLoop)
        ; Now we reference the data section to see where this filename should go
        ForEach(Index())
          ; Is the current base filename found in the datasection for this portable collection?
          If FindString(CurrentFile.s, Index()\BaseFilename, 1)
            ; Create the target filename string
            TargetDirString.s = TargetDir.s + Index()\Directory + "\"
            ; Create the unicode directory path at the target
            MakeSureDirectoryPathExists(TargetDirString.s)
            ; Check the source file for validity
            If FileSize(SourceDir.s + CurrentFile.s) <> -1
              ; Check to see if we are copying or moving the file
              Select Program\FileMode
                ; User has the copy flag set
                Case "Copy"
                  If CopyFile(SourceDir.s + CurrentFile.s, TargetDirString.s + CurrentFile.s)
                    Counter + 1
                    While WindowEvent() : Wend
                    AddGadgetItem(#Gadget_PortaSort_tosortto, -1, Index()\Directory + Chr(10) + Index()\BaseFilename + Chr(10) + "Okay")
                    SetWindowTitle(#Window_PortaSort, Program\WindowTitle +  Str(Counter) + " " + CurrentFile.s)
                    RemoveGadgetItem(#Gadget_PortaSort_tosortfrom, SortLoop)
                    LastLine(#Gadget_PortaSort_tosortto, Counter - 1)
                  Else
                    AddGadgetItem(#Gadget_PortaSort_errors, -1, "Cannot copy file" + Chr(10) + "<°)))o><²³  " + SourceDir.s + CurrentFile.s)
                  EndIf
                  ; User has the move flag set
                Case "Move"
                  If RenameFile(SourceDir.s + CurrentFile.s, TargetDirString.s + CurrentFile.s)
                    Counter + 1
                    While WindowEvent() : Wend
                    AddGadgetItem(#Gadget_PortaSort_tosortto, -1, Index()\Directory + Chr(10) + Index()\BaseFilename + Chr(10) + "Okay")
                    SetWindowTitle(#Window_PortaSort, Program\WindowTitle +  Str(Counter) + " " + CurrentFile.s)
                    RemoveGadgetItem(#Gadget_PortaSort_tosortfrom, SortLoop)
                    LastLine(#Gadget_PortaSort_tosortto, Counter - 1)
                  Else
                    AddGadgetItem(#Gadget_PortaSort_errors, -1, "Cannot move file" + Chr(10) + "<°)))o><²³  " + SourceDir.s + CurrentFile.s)
                  EndIf
                  ; 
              EndSelect
              ; Despite the filename in the list,w e could not find the physical file on disk
            Else
              AddGadgetItem(#Gadget_PortaSort_errors, -1, "File not found" + Chr(10) + "<°)))o><²³  " + SourceDir.s + CurrentFile.s)
            EndIf
            ; No match in the list for the current file
;           Else
;             AddGadgetItem(#Gadget_PortaSort_errors, -1, "No current match for" + Chr(10) + "<°)))o><²³  " + SourceDir.s + CurrentFile.s)
          EndIf
          ; Next datasection string to compare against
        Next
        ; Next filename in the list to be sorted
      Next SortLoop
      ; Let the user know that the sort was successfully finished
      AddGadgetItem(#Gadget_PortaSort_errors, -1, "Sort finished" + Chr(10) + "<°)))o><²³  All files specified in the index have been sorted")
      ; Dump unreferenced filenames to a list to be checked
      If CountGadgetItems(#Gadget_PortaSort_tosortfrom) <> 0
        If Program\DumpLeftOvers = "Yes"
          DumpLeftOvers()
        EndIf
      EndIf
      ; The sort was aborted as the target directory name was missing
    Else
      AddGadgetItem(#Gadget_PortaSort_errors, -1, "Sort aborted" + Chr(10) + "<°)))o><²³  Target sort directory was not specified")
    EndIf
    ; The sort was aborted as the target directory name and source directory name were the same
  Else
    AddGadgetItem(#Gadget_PortaSort_errors, -1, "Sort disallowed" + Chr(10) + "<°)))o><²³  The source and target directories must not be the same, bad things can happen")
  EndIf
  ; 
EndProcedure

; Get the source path for the PortableApps files to sort to

Procedure GetPortableAppsTargetPath()
  PortableAppsTargetPath.s = PathRequester("Where to sort Liberkey files from?", "")
  If PortableAppsTargetPath.s <> ""
    Program\PortableAppsTargetPath = PortableAppsTargetPath.s
    SetGadgetText(#Gadget_PortaSort_PortableAppsTargetDir, Program\PortableAppsTargetPath)
  EndIf
EndProcedure

; Get the source path for the PortableApps files to gather from

Procedure GetPortableAppsSourcePath()
  PortableAppsSourcePath.s = PathRequester("Where to gather PortableApps files from?", "")
  If PortableAppsSourcePath.s <> ""
    Program\PortableAppsSourcePath = PortableAppsSourcePath.s
    SetGadgetText(#Gadget_PortaSort_PortableAppsSourceDir, Program\PortableAppsSourcePath)
  EndIf
EndProcedure

; Get the target path for the LiberKey files to sort to

Procedure GetLiberKeyTargetPath()
  LiberKeyTargetPath.s = PathRequester("Where to sort Liberkey files to?", "")
  If LiberKeyTargetPath.s <> ""
    Program\LiberKeyTargetPath = LiberKeyTargetPath.s
    SetGadgetText(#Gadget_PortaSort_LiberkeyTargetDir, Program\LiberKeyTargetPath)
  EndIf
EndProcedure

; Get the source path for the LiberKey files to gather from

Procedure GetLiberKeySourcePath()
  LiberKeySourcePath.s = PathRequester("Where to gather LiberKey files from?", "")
  If LiberKeySourcePath.s <> ""
    Program\LiberkeySourcePath = LiberKeySourcePath.s
    SetGadgetText(#Gadget_PortaSort_LiberkeySourceDir, Program\LiberkeySourcePath)
  EndIf
EndProcedure

; Create a brand new INI file in the program directory if the default one is missing, with default values.

Procedure CreatePreferencesFile()
  CreatePreferences(Program\IniFile)
  PreferenceComment(" ")
  PreferenceComment("---------------------------------------------------------------------------------------")
  PreferenceGroup("Program Options")
  PreferenceComment("---------------------------------------------------------------------------------------")
  PreferenceComment(" ")
  WritePreferenceString("Last Index",                 "Liberkey")
  WritePreferenceString("Copy Or Move",               "Copy")
  WritePreferenceString("Dump LeftOvers",             "Yes")
  PreferenceComment(" ")
  PreferenceComment("---------------------------------------------------------------------------------------")
  PreferenceGroup("File Sort Paths")
  PreferenceComment("---------------------------------------------------------------------------------------")
  PreferenceComment(" ")
  WritePreferenceString("Liberkey Source Path",       "C:\Users\Fangles\Downloads\FlashGet Downloads\_Portable Software Collections\Liberkey\Files\")
  WritePreferenceString("Liberkey Target Path",       "C:\Users\Fangles\Downloads\PortaSort\LiberKey\")
  WritePreferenceString("PortableApps Source Path",   "C:\Users\Fangles\Downloads\FlashGet Downloads\_Portable Software Collections\PortableApps.com\")
  WritePreferenceString("PortableApps Target Path",   "C:\Users\Fangles\Downloads\PortaSort\PortableApps\")
  ClosePreferences()
EndProcedure

; Read the system preferences file or create it if missing

Procedure ReadPreferencesFile()
  ; If the INI file doesn't exist, create a default one
  If FileSize(Program\IniFile) = -1
    CreatePreferencesFile()
  EndIf
  ; Did we last sort LiberKey or PortableApps?
  Program\LastIndex                 = GetIniVal("Program Options", "Last Index")
  ; Shall we copy or move files?
  Program\FileMode                  = GetIniVal("Program Options", "Copy Or Move")
  ; Shall we copy or move files?
  Program\DumpLeftOvers             = GetIniVal("Program Options", "Dump LeftOvers")
  ; What was the last LiberKey source path used?
  Program\LiberkeySourcePath        = GetIniVal("File Sort Paths", "Liberkey Source Path")
  ; What was the last LiberKey taget path used?
  Program\LiberKeyTargetPath        = GetIniVal("File Sort Paths", "Liberkey Target Path")
  ; What was the last PortableApps source path used?
  Program\PortableAppsSourcePath    = GetIniVal("File Sort Paths", "PortableApps Source Path")
  ; What was the last PortableApps target path used?
  Program\PortableAppsTargetPath    = GetIniVal("File Sort Paths", "PortableApps Target Path")
EndProcedure

; Save all preferences at program end

Procedure SavePreferencesFile()
  ; If the INI file doesn't exist, create a default one
  If FileSize(Program\IniFile) = -1
    CreatePreferencesFile()
  EndIf
  SetIniVal("Program Options", "Last Index",                Program\LastIndex)
  SetIniVal("Program Options", "Copy Or Move",              Program\FileMode)
  SetIniVal("Program Options", "Dump LeftOvers",            Program\DumpLeftOvers)
  SetIniVal("File Sort Paths", "Liberkey Source Path",      Program\LiberkeySourcePath)
  SetIniVal("File Sort Paths", "Liberkey Target Path",      Program\LiberKeyTargetPath)
  SetIniVal("File Sort Paths", "PortableApps Source Path",  Program\PortableAppsSourcePath)
  SetIniVal("File Sort Paths", "PortableApps Target Path",  Program\PortableAppsTargetPath)
EndProcedure

If Window_PortaSort()
  ; Read startup preferences. Last index, move or copy, liberkey and portableapps sort paths
  ReadPreferencesFile()
  ; Add message about config read
  AddGadgetItem(#Gadget_PortaSort_errors, -1, "Read config file" + Chr(10) + "<°)))o><²³  " + Program\IniFile)
  ; Add the Liberkey or PortableApps.Com file index choices
  AddGadgetItem(#Gadget_PortaSort_SelectIndex, -1, "LiberKey")
  AddGadgetItem(#Gadget_PortaSort_SelectIndex, -1, "PortableApps")
  ; Set the index name to last used
  SetGadgetText(#Gadget_PortaSort_SelectIndex, Program\LastIndex)
  ; Add message about config read
  AddGadgetItem(#Gadget_PortaSort_errors, -1, "Last index used loaded" + Chr(10) + "<°)))o><²³  " + Program\IniFile)
  ; Set the source and target directories in the main screen
  Select Program\LastIndex
    Case  "LiberKey"
      SetGadgetText(#Gadget_PortaSort_SourceDir, Program\LiberkeySourcePath)
      SetGadgetText(#Gadget_PortaSort_TargetDir, Program\LiberKeyTargetPath)
    Case  "PortableApps"
      SetGadgetText(#Gadget_PortaSort_SourceDir, Program\PortableAppsSourcePath)
      SetGadgetText(#Gadget_PortaSort_TargetDir, Program\PortableAppsTargetPath)
  EndSelect
  ; Add message about config read
  AddGadgetItem(#Gadget_PortaSort_errors, -1, "Last index source and target set" + Chr(10) + "<°)))o><²³  " + Program\IniFile)
  ; Set the config screen source and target directories
  SetGadgetText(#Gadget_PortaSort_LiberkeySourceDir,      Program\LiberkeySourcePath)
  SetGadgetText(#Gadget_PortaSort_LiberkeyTargetDir,      Program\LiberKeyTargetPath)
  SetGadgetText(#Gadget_PortaSort_PortableAppsSourceDir,  Program\PortableAppsSourcePath)
  SetGadgetText(#Gadget_PortaSort_PortableAppsTargetDir,  Program\PortableAppsTargetPath)
  ; Add message about config read
  AddGadgetItem(#Gadget_PortaSort_errors, -1, "Config screen paths loaded" + Chr(10) + "<°)))o><²³  " + Program\IniFile)
  ; Setup copy or move mode
  If Program\FileMode = "Copy"
    SetGadgetState(#Gadget_PortaSort_oCopy, 1)
  ElseIf Program\FileMode = "Move"
    SetGadgetState(#Gadget_PortaSort_oMove, 1)
  EndIf
  ; Dump a leftover files report or not
  If Program\DumpLeftOvers = "Yes"
    SetGadgetState(#Gadget_PortaSort_cbDumpLeftovers, 1)
  ElseIf Program\DumpLeftOvers = "No"
    SetGadgetState(#Gadget_PortaSort_cbDumpLeftovers, 0)
  EndIf
  ; Add message about config read
  AddGadgetItem(#Gadget_PortaSort_errors, -1, "File copy mode set" + Chr(10) + "<°)))o><²³  " + Program\IniFile)
  Program\WindowTitle =  "<°)))o><²³  " + #Program
  ChooseIndex()
  ;SetWindowTitle(#Window_PortaSort, "<°)))o><²³  " + #Program)
  AddGadgetItem(#Gadget_PortaSort_errors, -1, "Startup" + Chr(10) + "<°)))o><²³  " + #Program + "Ready to work")
  Program\QuitValue  = 0
  Repeat
    Select  WaitWindowEvent()
      Case  #PB_Event_CloseWindow
        Select  EventWindow()
          Case  #Window_PortaSort                       : Program\QuitValue  = 1
        EndSelect
        ; 
      Case  #PB_Event_Menu
        Select  EventMenu()
          Case  #Shortcut_PortaSort_Exit                : Program\QuitValue  = 1
        EndSelect
        ; 
      Case  #PB_Event_Gadget
        Select  EventGadget()
          ; Sort the files now
          Case  #Gadget_PortaSort_runjob                : SortFiles()
          ; Choose the correct file index
          Case  #Gadget_PortaSort_SelectIndex
            Select  EventType()
              Case  #PB_EventType_Change                : ChooseIndex()
            EndSelect
          Case  #Gadget_PortaSort_GetSortFiles          : ChooseIndex()
          ; Shall we move or copy the files
          Case  #Gadget_PortaSort_oMove                 : Program\FileMode = "Move"
          Case  #Gadget_PortaSort_oCopy                 : Program\FileMode = "Copy"
          ; 
          Case  #Gadget_PortaSort_cbDumpLeftovers       : CheckDumpMode()
          ; 
          Case  #Gadget_PortaSort_GetLiberkeySource     : GetLiberKeySourcePath()
          Case  #Gadget_PortaSort_GetLiberkeyTarget     : GetLiberKeyTargetPath()
          Case  #Gadget_PortaSort_GetPortableAppsSource : GetPortableAppsSourcePath()
          Case  #Gadget_PortaSort_GetPortableAppsTarget : GetPortableAppsTargetPath()
          ; 
          Case  #Gadget_PortaSort_exit                  : Program\QuitValue = 1
          ; 
        EndSelect
    EndSelect
  Until Program\QuitValue = 1
  ; Save system preferences
  SavePreferencesFile()
  ; 
  CloseWindow(#Window_PortaSort)
EndIf
End

Re: LiberKey offline files sorter

Posted: Wed Dec 14, 2011 10:39 am
by Kwai chang caine
Thank for sharing 8)

Re: LiberKey offline files sorter

Posted: Thu Dec 15, 2011 5:21 am
by Fangbeast
Under Windows 7 (and Vista I imagine), your move/rename functions may fail even if you have administrative permission in the directories that you are working with.

Not sure if the format is correct but it works here so save the following as "PortaSort.manifest" in the same directory where you are running the program and your delete/rename should work if you are doing that instead of copy.

The examples to do this were found throughout the forum after a suggestion from jassing. (Sources: mback2k and others)

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
    version="0.00"
    processorArchitecture="X86"
    name="PortaSort"
    type="win32"
/>
<description>LiberKey and PortableApps offline files sorter.</description>
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.MSXML2"
            version=""
            processorArchitecture="X86"
            publicKeyToken=""
            language="*"
        />
    </dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
        <requestedPrivileges>
            <requestedExecutionLevel
                level="asInvoker"
            uiAccess="false"/>
        </requestedPrivileges>
    </security>
</trustInfo>
</assembly>