The favorites are in the [chanfolder] section of mirc.ini. I don't recommend writing to it with a script, best to backup mirc.ini to somewhere safe, then paste from elsewhere using notepad. From playing round with it, it looks like each line is formatted where the #channelname is either by itself or followed by several optional fields like:

#channelname,"description",password,"NetworkGroupname1,NetworkGroupname2",1,1

... where the last 2 fields being 1 are:

1 if join-on-connect, otherwise blank
1 if minimize-on-join, otherwise blank

If the optional fields aren't set, they're blank rather than have a series of commas.

You can browse thru the favorites like:

//hfree -w favorites | hload -m1i favorites $mircini chanfolder

This shows the items being loaded in reverse alphabetical order:

//var %i 1 | while ($hget(favorites,%i).item) { echo -a $v1 $hget(favorites,$v1) | inc %i }

and that's the way they would save to disk:

/hsave -ins favorites favs.txt chanfolder