I just saw this and while you could potentially achieve what you’re asking by using in game scripting with the /run command and some LUA code inline it wouldn’t be actually very inefficient in the long term due to many in game limitations and restrictions.
Essentially you’re better off to do this through some in game addon and custom LUA code to achieve what you’re wanting to do.
Now with all that said it is definitely worth pointing out that a user by the name of Jejanim has actually done something very similar to this through a Weakaura. So you will obviously need the Weakauras addon installed first which will then allow you to import and install his Weakaura in game.
So with that all said you can access his Weakaura which is updated to the latest Dragonflight Release 10.1 from here - Openables (Containers, Boxes, etc) - Weakaura by Jejanim
In terms of the list of items that is currently included in this WeakAura at the moment is the following:
ITEMID. __ ITEM NAME
205248,
205247,
205346, – Hidden Niffen Treasure
205964, – Small Loammian Supply Pack
205369, – Appreciative Researcher’s Gift
205370, – Researcher’S Gift
205226, – Cavern Racer’s Purse
204724, – Drake’s Small Chest
205983, – Scentsational Niffen Treasures
205423, – Shadowflame Residue Sack
205371, – Appreciative Researcher’s Scrounged Goods
205347, – Gathered Niffen Resources
204381, – Brimming Valdrakken Accord Supply Pack
205373, – Researcher’s Scrounged Goods
206135, – Heroic Dungeon Delver’s Trophy Chest
– 10
50160, – Lovely Dress Box
54537, – Heart-Shaped Box (Love is in the air)
93724, – Darkmoon Game Prize
21746, – Lucky Red Envelope (Lunar Festival)
202055, – Dreamer’s Vision
202057, – Earthwarden’s Price
202056, – Keeper’s Glory
202054, – Queen’s Gift
199474, – Overflowing Maruuk Centaur Supply Satchel (epic)
199472, – Overflowing Dragon Expedition Supply Pack
203476, – Primalist Cache (rare)
198395, – Dull Spined Clam
202371, – Glowing Primalist Cache (epic)
200156, – Amethyzarite Geode
201326, – Draconic Satchel of Cooperation
192893, – Jeweled Dragon’s Heart
201343, – Bag of Cloth Armor Reagents
201353, – Bag of Mail Armor Reagents
189765, – Maruuk Centaur Supply Satchel
198866, – Small Iskaaran Supply Pack
198863, – Small Dragon Expedition Supply Pack
201250, – Victorious Contender’s Strongbox
202080, – Cache of Vault Treasures (hc)
202079, – Cache of Vault Treasures (nhc)
192892, – Timewatcher’s Patience 1
202058, – Timewatcher’s Patience 3
201817, – Twilight Cache
201754, – Obsidian Forgemaster’s Cache
200069, – Obsidian Cache
202052, – Timewatcher’s Patience 2
200515, – Grand Hunt Spoils (green))
200513, – Grand Hunt Spoils
200095, – Supply-Laden Soup Pot
202142, – Dragonbane Keep Strongbox
199192, – Dragon Racer’s Purse
202097, – Bulging Box of Skins and Scales
200073, – Valdrakken Treasures
201352, – Bag of Leather Reagents
198868, – Small Valdrakken Accord Supply Pack
200468, – Grand Hunt Spoils
200072, – Dragonbane Keep Strongbox
200070, – Obsidian Strongbox
201728, – Vakril’s Strongbox
– 9.2
191701, – Bag of Explored Souls
187781, – Olea Cache
191303, – Overflowing Chest of Riches
190656, – Cache of Sepulcher Treasures (hc))
187787, – Ephemera Orb
190655, – Cache of Sepulcher Treasures
191040, – Cache of Sepulcher Treasures (252+)
191139, – Tribute of the Enlightened Elders (new)
190610, – Tribute of the Enlightened Elders
190339, – Enlightened Offering
190178, – Pouch of Protogenic Provisions
– Valor Point Rewards
185832, --Shipment of Elethium Ore
– 9.1
187028, – Supplies of the Archivists’ Codex
186650, – Death’s Advance Supplies
186533, – Cache of SAnctum Treasues (hc)
187551, – Small Korthian Supply Chest
186531, – Cache of Sanctum Treasures (nhc)
185992, – War Chest of the Undying Army
187543, – Death’s Advance War Chest
186196, – Death’s Advance War Chest 2?
185991, – War Chest of the Wild Hunt
187354, – Abandoned Broker Satchel
185972, – Tormentor’s Cache
187440, – Feather-Stuffed Helm
186691, – Gold Filled Satchel
186688, – Gold Filled Wash Bucket
186680, – Gold Filled Boot
186708, – Gold Filled Paint Brush Cup
186706, – Gold Filled Hat
186707, – Gold Filled Crate
186693, – Gold Filled Wheelbarrow
186705, – Gold Filled Chalice
186970, – Feeder’s Hand and Key
187351, – Stygic Cluster
185990, – Harvester’s War Chest
187029, – Mysterious Gift from Ve’nari
185993, – Ascended War Chest
187278, – Talon-Pierced Mawsworn Lockbox
187576, – Korthian Skinning Cache
187577, – Korthian Meat Cache
187575, – Korthian Fishing Cache
187574, – Brokers’ Overflowing Bucket
187572, – Brokers’ Herbalism Mote of Potentation
187573, – Brokers’ Enchanting Mote of Potentation
187569, – Brokers’ Tailoring Mote of Potentation
187571, – Brokers’ Mining Mote of Potentation
187570, – Brokers’ Skinning Mote of Potentation
– Shadowlands
180980, --Journeyman’s Large Satchel
180976, --Artisan’s Satchel
180974, --Novice’s Satchel
180085, --Kyrian Keepsake
184047, --Ascended Chest of Arms
184048, --Weapon Satchel of the Wild Hunt
184045, --Martial Tithe of the Court of Harvesters
184046, --Undying Army Weapon Cache
171210, --Satchel of Nature’s Bounty
184522, --Veiled Satchel of Cooperation
183702, --Nature’s Splendor
183699, --Exquisite Ingredients
184395, --Fallen Adventurer’s Cache
178040, --Condensed Stygia
180646, --Supplies of the Undying Army
180648, --Court of Harvesters Supplies
184869, --Cache of Nathrian Treasures
184868, --Cache of Nathrian Treasures (hc)
180647, --Ascended Supplies
180649, --Wild Hunt Supplies
180592, --Trapped Stonefiend
184635, --Adventurer’s Mining Cache
184630, --Adventurer’s Tailoring Cache
184636, --Adventurer’s Skinning Cache
184634, --Adventurer’s Herbalism Cache
184631, --Adventurer’s Enchanting Cache
184637, --Hero’s Meat Cache
184638, --Hero’s Fish Cache
184646, --Hero’s Mining Cache
184647, --Hero’s Herbalism Cache
184645, --Hero’s Skinning Cache
184648, --Hero’s Enchanting Cache
184644, --Hero’s Tailoring Cache2
184641, --Champion’s Mining Cache
184642, --Champion’s Herbalism Cache
184633, --Champion’s Meat Cache
184632, --Champion’s Fish Cache
184639, --Champion’s Tailoring Cache
184643, --Champion’s Enchanting Cache
184640, --Champion’s Skinning Cache
181372, --Tribute of the Ascended
181556, --Tribute of the Court
181476, --Tribute of the Wild Hunt
181733, --Tribute of the Duty-Bound
181741, --Tribute of the Paragon
181732, --Tribute of the Ambitious
181557, --Favor of the Court
181475, --Bounty of the Grove Wardens
184843, --Salvaged Supplies
171209, --Blooded Satchel
183703, --Bonesmith’s Satchel
180355, --Ornate Pyx
178128, --Pouch of Shinies
– BFA
168740, --Blingtron 7000 Gift Package
166297, --Order of Embers Supplies
– Legion
136926, --Nightmare Pod
– OLD
7973 – Big-Mouth Clams