I wrote my own script to do this a long time ago and decided to dust it off and make some improvements. It should work with Classic Era, Wrath Classic, and Dragon Flight.
Lua Code:
local function UnequipAll()
local invslot,lastslot=EQUIPPED_FIRST or INVSLOT_FIRST_EQUIPPED,EQUIPPED_LAST or INVSLOT_LAST_EQUIPPED;
ClearCursor();
for bag=NUM_BAG_SLOTS or NUM_TOTAL_EQUIPPED_BAG_SLOTS,0,-1 do
local free,type=(C_Container or _G).GetContainerNumFreeSlots(bag);
free=(type==0 and free or 0);
for _=1,free do
PickupInventoryItem(invslot);
(bag==0 and PutItemInBackpack or PutItemInBag)((C_Container or _G).ContainerIDToInventoryID(bag));
invslot=invslot+1;
if invslot>lastslot then return; end
end
end
end