I had the same issues with the whole multicmd thingy to find out the caravan members' IDs. Just didn't work. Luckily, I had seasonal autosaves thanks to playing with LNP and was able to get their IDs from those. The IDs turned out to be in the 30000s range, so I would have probably given up before finding them through trial and error anyway.
* Find out if you have a backup save from before the bugged caravan arrived. If you don't know exactly when that happened, just load a bunch of old saves and check the stocks screen for those unowned red items on the map's edge. Find the last save that doesn't have them.
* Make an additional backup of that save!
* Load the save and let the game run until the caravan comes. The caravan bugging out seems to be a rare random occurrence, so they'll probably arrive just fine this time. If not, quit the game, restore your backup save, try again.
* Make sure every member of the caravan - merchants, guards, horses, wagons - is on the map. I waited until they were all at the trade depot to be sure.
* Use the "u"nits screen to zoom in on the caravan members one by one and type "teleport -showunitid" to get their ID (their IDs should be subsequent and they
should appear in the list in descending order, I think, so you can double-check if you ID range is correct by counting how many units there are).
* Load up your bugged game.
* OPTIONAL: build an
execution chamber safe containment room with a raised drawbridge so you can atomsmash the entire caravan into oblivion. After years of being stuck on the map, a few of them
will go berserk. Prepare memorial slabs.
* Put the cursor where you want the merchants and use "teleport -unit <ID>" to move them. I think multicmd would work fine now as long as all (or most, see below) unit IDs are valid, but I teleported them one by one anyway. You can use the arrow-up key in the DFhack console to restore the last command you typed and just replace the numbers.
NOTE: there may still be some invalid IDs since, apparently, the caravan won't consist of
exactly the same number of members every time, which seems to be determined only upon actually entering the map. In my case, the last three IDs I had determined from the backup save weren't there in the bugged game. To make sure I didn't miss anyone, I checked about 20 additional ID numbers at both ends of the range, but they were all non-existent.
* Let the game run for a few frames, wait until everyone's teleported in and do whatever you want to get rid of them.
Good luck, I hope it works for you!
EDIT: PatrikLundell beat me to it and his method is probably faster and easier
I'll leave mine here anyway just in case you need it.