I'd consider writing a robust macro, than manually building a .D (which indeed takes a great while). Not only will it save time, but will also automatically attend new mod spells (if any).
In theory, using a macro to code a .D file sounds like a neat idea, but I'm not sure how feasible it would be in practice. For now, I'd rather do things manually than risking to have nonsensical dialogue lines show up due to some obscure typo in the macro code.
FWIW, it's not as bad as I had expected. A large part of the dialogue code is repeated for each reply so copy -> paste works well enough. Here's an example:
BEGIN ~RR#SCRL~
IF ~True()~ THEN BEGIN RR#SCRL99
SAY @8221 // (This ability allows an experienced arcane spellcaster to scribe any spell that he can cast onto a scroll. However, the costs for any raw materials that are used in the process must be paid. In order to scribe a scroll, the respective spell must be currently memorized.)
IF ~~ THEN GOTO RR#SCRL00
END
IF ~~ THEN BEGIN RR#SCRL00
SAY @8222 // (Select a spell level:)
IF ~PartyGoldGT(49)~ THEN REPLY @8230 GOTO RR#SCRL01 // 1st level spells (50 gp)
IF ~PartyGoldGT(99)~ THEN REPLY @8231 GOTO RR#SCRL02 // 2nd level spells (100 gp)
IF ~PartyGoldGT(149)~ THEN REPLY @8232 GOTO RR#SCRL03 // 3rd level spells (150 gp)
IF ~PartyGoldGT(249)~ THEN REPLY @8233 GOTO RR#SCRL04 // 4th level spells (250 gp)
IF ~PartyGoldGT(499)~ THEN REPLY @8234 GOTO RR#SCRL05 // 5th level spells (500 gp)
IF ~PartyGoldGT(999)~ THEN REPLY @8235 GOTO RR#SCRL06 // 6th level spells (1000 gp)
IF ~PartyGoldGT(1499)~ THEN REPLY @8236 GOTO RR#SCRL07 // 7th level spells (1500 gp)
IF ~PartyGoldGT(2499)~ THEN REPLY @8237 GOTO RR#SCRL08 // 8th level spells (2500 gp)
IF ~PartyGoldGT(4999)~ THEN REPLY @8238 GOTO RR#SCRL09 // 9th level spells (5000 gp)
IF ~~ THEN REPLY @8250 EXIT // (Do not scribe any scrolls.)
END
IF ~~ THEN BEGIN RR#SCRL01 // 1st level spells (50 gp)
SAY @8260 // (Choose which spell to scribe onto a scroll.)
IF ~HaveSpell(WIZARD_GREASE)~ THEN REPLY #12030 DO ~TakePartyGold(50) GiveItemCreate("SCRL66",Myself,1,1,1)~ EXIT // Grease
IF ~HaveSpell(WIZARD_ARMOR)~ THEN REPLY #12031 DO ~TakePartyGold(50) GiveItemCreate("SCRL67",Myself,1,1,1)~ EXIT // Armor
IF ~HaveSpell(WIZARD_BURNING_HANDS)~ THEN REPLY #12074 DO ~TakePartyGold(50) GiveItemCreate("SCRL68",Myself,1,1,1)~ EXIT // Burning Hands
IF ~HaveSpell(WIZARD_CHARM_PERSON)~ THEN REPLY #12045 DO ~TakePartyGold(50) GiveItemCreate("SCRL69",Myself,1,1,1)~ EXIT // Charm Person
IF ~HaveSpell(WIZARD_COLOR_SPRAY)~ THEN REPLY #12075 DO ~TakePartyGold(50) GiveItemCreate("SCRL70",Myself,1,1,1)~ EXIT // Color Spray
IF ~HaveSpell(WIZARD_BLINDNESS)~ THEN REPLY #12015 DO ~TakePartyGold(50) GiveItemCreate("SCRL71",Myself,1,1,1)~ EXIT // Blindness
IF ~HaveSpell(WIZARD_FRIENDS)~ THEN REPLY #12046 DO ~TakePartyGold(50) GiveItemCreate("SCRL72",Myself,1,1,1)~ EXIT // Friends
IF ~HaveSpell(WIZARD_PROTECTION_FROM_PETRIFICATION)~ THEN REPLY #12024 DO ~TakePartyGold(50) GiveItemCreate("SCRL73",Myself,1,1,1)~ EXIT // Protection From Petrification
IF ~HaveSpell(WIZARD_IDENTIFY)~ THEN REPLY #12040 DO ~TakePartyGold(50) GiveItemCreate("SCRL75",Myself,1,1,1)~ EXIT // Identify
IF ~HaveSpell(WIZARD_INFRAVISION)~ THEN REPLY #12039 DO ~TakePartyGold(50) GiveItemCreate("SCRL76",Myself,1,1,1)~ EXIT // Infravision
IF ~HaveSpell(WIZARD_MAGIC_MISSILE)~ THEN REPLY #12052 DO ~TakePartyGold(50) GiveItemCreate("SCRL77",Myself,1,1,1)~ EXIT // Magic Missile
IF ~HaveSpell(WIZARD_PROTECTION_FROM_EVIL)~ THEN REPLY #12023 DO ~TakePartyGold(50) GiveItemCreate("SCRL78",Myself,1,1,1)~ EXIT // Protection From Evil
IF ~HaveSpell(WIZARD_SHIELD)~ THEN REPLY #12053 DO ~TakePartyGold(50) GiveItemCreate("SCRL79",Myself,1,1,1)~ EXIT // Shield
IF ~HaveSpell(WIZARD_SHOCKING_GRASP)~ THEN REPLY #12076 DO ~TakePartyGold(50) GiveItemCreate("SCRL80",Myself,1,1,1)~ EXIT // Shocking Grasp
IF ~HaveSpell(WIZARD_SLEEP)~ THEN REPLY #12047 DO ~TakePartyGold(50) GiveItemCreate("SCRL81",Myself,1,1,1)~ EXIT // Sleep
IF ~HaveSpell(WIZARD_CHILL_TOUCH)~ THEN REPLY #12067 DO ~TakePartyGold(50) GiveItemCreate("SCRL82",Myself,1,1,1)~ EXIT // Chill Touch
IF ~HaveSpell(WIZARD_CHROMATIC_ORB)~ THEN REPLY #12054 DO ~TakePartyGold(50) GiveItemCreate("SCRL83",Myself,1,1,1)~ EXIT // Chromatic Orb
IF ~HaveSpell(WIZARD_LARLOCH_MINOR_DRAIN)~ THEN REPLY #12068 DO ~TakePartyGold(50) GiveItemCreate("SCRL84",Myself,1,1,1)~ EXIT // Larloch's Minor Drain
IF ~HaveSpell(WIZARD_REFLECTED_IMAGE)~ THEN REPLY #25866 DO ~TakePartyGold(50) GiveItemCreate("SCRL5U",Myself,1,1,1)~ EXIT // Reflected Image
IF ~HaveSpell(WIZARD_FIND_FAMILAR)~ THEN REPLY #8072 DO ~TakePartyGold(50) GiveItemCreate("SCRL6D",Myself,1,1,1)~ EXIT // Find Familiar
IF ~HaveSpell(WIZARD_SPOOK)~ THEN REPLY #38586 DO ~TakePartyGold(50) GiveItemCreate("SCRLA6",Myself,1,1,1)~ EXIT // Spook
IF ~~ THEN REPLY @8261 GOTO RR#SCRL00 // Select a different spell level
END