Tema: Re: Man tamsus miskas, gal pasviesit?
Autorius: Laimis
Data: 2015-09-30 00:05:08
    # file named - Thunderbird_Filters-Sorted-By-Name.ps1

    <#
       Sita faila paleisti su "Run with PowerShell" desiniu peles klavise
    this script sorts the tbird message filter rules file by filter name.

    i recommend ...
    - copying the original file to a folder - c:\Users\Sigitas\AppData\Roaming\Thunderbird\Profiles\qn08m9m5.default\Mail\Local Folders, for example
    - run the script
    - view the new file in a text editor like notepad to see if it really worked [*grin*]
    - copy the new file to the original location
    - rename the oiginal file - ex. = msgFilterRules.dat.bak
    - rename the new, sorted file to msgFilterRules.dat

    you can do it all in one swell foop if you desire by ...
    - setting $Directory to the tbird mail account folder where the msgFilterRules.dat file is located
    - un-commenting the first $OutFile line and commenting out the second $OutFile line
    #>
$MailDir = "C:\Users\Sigitas\AppData\Roaming\Thunderbird\Profiles\qn08m9m5.default\Mail"
$Dirs = @("Local Folders", "mail.zebra.lt")	


foreach($TargetDir in $Dirs | ForEach-Object { Join-Path $MailDir $_ }) {
    $InFile = Join-Path $TargetDir "msgFilterRules.dat"

	If (-Not (Test-Path $Infile)) { continue }

    # live dangerously! overwrite your input file with your output file!
    # $OutFile = $InFile
    $OutFile = -join ($InFile, ".", (get-date).ToString("yyyy-MM-dd"))
    $LineBreak = "linebreak"
    $FilterStart = "filterstart"
    $SortFirst = "a_"
    $NewFilterList = ""

    # read the file - it comes in as an array
    $OldFilterList = get-content $InFile

    # convert the array into a l-o-n-g string with appropriate re-splitter markers
    foreach($line in $OldFilterList)
        {
        # mark the version line so it always sorts first
        if($line -match "version=")
            {
            $line = $SortFirst, $line -join ""
            }
        # mark the start of a filter   
        if($line -match "name=")
            {
            $line = $FilterStart, $line -join ""
            }
        # mark the end of a line   
        $line = $line, $LineBreak -join " "
        # build the l-o-n-g string
        $NewFilterList = $NewFilterList, $line -join ""
        }
    # split it at the filter marker, sort it, join it back into a string
    # - note that the filter marker is gone now
    $NewFilterList = (($NewFilterList -split $FilterStart) | sort-object) -join ""
    # split at the linebreak marker
    # - note that the linebreak marker is gone now
    $NewFilterList = $NewFilterList -split $LineBreak
    # get rid of the no longer needed "a_" on the "version=" line
    # - it otta ALWAYS be item zero
    $NewFilterList[0] = $NewFilterList[0] -replace $SortFirst, ""

    # write the new file
    set-content $Outfile -value $NewFilterList
 
}

3Dastronomyagricultureaudioautosautos.audiautos.audioautos.binariesautos.bmwautos.clubautos.fordautos.hondacrxautos.japanautos.mercedesautos.opelautos.sportautos.volvoautos.vwaviaavia.binariesbankcardsbinariesbooksbuildingcinemacommercecomp.hardwarecomp.softwarecomp.lietuvinimascomp.networksculturedarbas.ieskaudarbas.siulaudesigneconomicselectronicsfaunafauna.aquafauna.binariesfishingflorafotofoto.binariesgamesgames.csgames.onlinegsmgurmanaihumourhumour.binariesinternetlawmicrosoftmotomusicmusic.binariesmusic.instrumentsmusic.LT.binariesnavigacijaphppoliticsprogrammingrpgsportstudyingsveikatatalktesttranslationtransportationtraveltravel.binariestvunixvideovideo.binarieswatersportswwwwww.flashpdaautos.supermama.ltmobiledarbasretro.3Dretro.agricultureretro.astronomyretro.audioretro.autosretro.autos.audiretro.autos.audioretro.autos.binariesretro.autos.bmwretro.autos.clubretro.autos.fordretro.autos.hondacrxretro.autos.japanretro.autos.mercedesretro.autos.opelretro.autos.sportretro.autos.supermamaretro.autos.supermama.ltretro.autos.volvoretro.autos.vwretro.aviaretro.avia.binariesretro.bankcardsretro.beosretro.binariesretro.booksretro.buildingretro.cinemaretro.commerceretro.compretro.comp.hardwareretro.comp.lietuvinimasretro.comp.networksretro.comp.softwareretro.cultureretro.darbasretro.darbas.ieskauretro.darbas.siulauretro.designretro.economicsretro.electronicsretro.e-vejasretro.faunaretro.fauna.aquaretro.fauna.binariesretro.fishingretro.floraretro.fotoretro.foto.binariesretro.gamesretro.games.csretro.games.onlineretro.games.rpgretro.genealogijaretro.gsmretro.gurmanairetro.humourretro.humour.binariesretro.internetretro.YZFretro.YZF.nebukretro.YZF.nebuk.netikintisretro.YZF.nebuk.netikintis.bukretro.YZF.nebuk.netikintis.buk.tikintisretro.lawretro.microsoftretro.mobileretro.motoretro.musicretro.music.binariesretro.music.instrumentsretro.music.LTretro.music.LT.binariesretro.navigacijaretro.newsretro.news.taisyklesretro.newuserretro.pdaretro.phpretro.politicsretro.programmingretro.rpgretro.sportretro.studyingretro.sveikataretro.talkretro.translationretro.transportationretro.travelretro.travel.binariesretro.tvretro.unixretro.videoretro.video.binariesretro.watersportsretro.wwwretro.www.flashdiylt.rkm.news.announcelt.rkm.news.newuser