Script to sort aliases

Some years ago I developed a script to sort aliases, placing wildcarded aliases at the bottom.  It was updated to support the new $LOCALDOMAIN$ format of wildcards.

Why would you want this?  Well, two reasons.  First, a sorted list makes it a lot easier to find what you’re looking for.  Second, if you add a non-wildcard alias below a wildcarded alias, the wildcarded alias may take effect first — If you’re manually adding aliases, you can hopefully remember to fix the order, but if you add aliases via a script, it’s important to get the sort order right.

I ran this on an hourly basis for several years, but please test this before deploying as I pulled it from some notes and not a live batch file.

@ECHO OFF
:MDSortAliases
C:
CD C:\MDaemon\App
FIND “$LOCALDOMAIN$” < ALIAS.DAT > ALIAS-WILD1.BAK
FIND “*” < ALIAS.DAT > ALIAS-WILD2.BAK
FIND “*” /v < ALIAS.DAT | FIND “$LOCALDOMAIN$” /v /i> ALIAS-NONW.BAK
SORT < ALIAS-NONW.BAK > ALIAS.DAT
SORT < ALIAS-WILD1.BAK >> ALIAS.DAT
SORT < ALIAS-WILD2.BAK >> ALIAS.DAT
DEL alias-wild1.bak
DEL alias-wild2.bak
DEL alias-nonw.bak
echo. > alias.sem

The above will sort aliases into three groups, non-wildcarded aliases, $LOCALDOMAIN$ aliases, then other wildcard aliases.  You can change the order by changing the names of the files in the SORT lines above.  Again, please backup and test first, I take no responsibility if your system bursts into flame after trying the above.

I make the potentially dangerous assumption that MDaemon is installed at C:\MDaemon\ — If not, please change the path.