If you want to: You can use DoItAll for this (written by Randacrtyl in the addon comments as well!)
It got the same feature and supports FCOItemSaver marked items (not moved) as well as AdvancedFilters + plugins and FCOCraftFilter.
Also got other featrues like extract all, refine all, attach all to mail, trade all, etc.
Else try to change the function to this (untested):
Seems the slotIndex was not found somehow so I've tried to look for slotIndex or slot, else do not add the item.
Lua Code:
local function DepositAllItems(button)
local window = button:GetParent():GetNamedChild("Backpack")
local delayStep = 300
local toBagId
local fromBagId = BAG_BACKPACK
if button.guild == true then toBagId = BAG_GUILDBANK
else toBagId = BAG_BANK end
local tempitems = {}
local items = {}
for _,v in pairs(window.data) do
local slotIndex = v.data.slotIndex or v.data.slot
if slotIndex then
tempitems[slotIndex] = v.data
end
end
for _,v in pairs(tempitems) do
table.insert(items, v)
end
MoveItems(toBagId, fromBagId, items, delayStep)
end