This should work, just have one backpack solely for this purpose. for example a bag with 10 enchanted sapphires and nothing else.

Code:
-- I recommend having one backpack or bag for the enchant to take place, 
-- because the enchanted sapphires needs to be on spot 1 and the weapon at spot 0 when enchanting.
local bp = 'dragon backpack'
  
while(true) do
    c = Container.GetByName(bp)
    if(Self.Weapon().id == 7383) then -- Relic Sword
        for spot = 0, c:ItemCount()-1 do
            if c:GetItemData(spot).id == 675 then -- Small Enchanted Sapphire
                Self.Dequip("weapon", c)
                wait(400,500)
                c:UseItemWithContainerItem(1, bp, 0)
                wait(400,500)
                Self.Equip(680, "weapon") -- icy relic sword
            end
        end
    end
    wait(2000)
end