# How do I iterate through items right-click-drag-and-dropped context menu items?

**URL:** <https://resource.dopus.com/t/how-do-i-iterate-through-items-right-click-drag-and-dropped-context-menu-items/40229>\
**Category:** Help & Support\
**Tags:** vbscript\
**Created:** [January 3, 2022, 11:20pm UTC](https://resource.dopus.com/t/how-do-i-iterate-through-items-right-click-drag-and-dropped-context-menu-items/40229 "2022-01-03T23:20:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cwm9](https://resource.dopus.com/letter_avatar_proxy/v4/letter/c/898d66/32.png) [@cwm9](https://resource.dopus.com/u/cwm9)\
**Post date:** [January 3, 2022, 11:20pm UTC](https://resource.dopus.com/t/how-do-i-iterate-through-items-right-click-drag-and-dropped-context-menu-items/40229/1 "2022-01-03T23:20:30Z")

</div>

When files are simply left-click dragged from one tab to another, I have no problem iterating the list via data.sourcetab.selected\_files(i).

But if I select files and then right-click-drag them, I cannot use data.sourcetab.selected\_files(i) (data.sourcetab.stats.selfiles is 0, no matter how many files I dragged.)

How do I get the list of files I dropped?

Thanks

---

<div class="post-metadata">

**Author:** ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)\
**Post date:** [January 4, 2022, 7:50am UTC](https://resource.dopus.com/t/how-do-i-iterate-through-items-right-click-drag-and-dropped-context-menu-items/40229/2 "2022-01-04T07:50:17Z")

</div>

There isn't a source tab in that context, but the list of files is included in the Command object that's given to the script:

```javascript
function OnClick(clickData)
{
	var cmd = clickData.func.command;
	DOpus.Output("Selected items:");
	if (cmd.files.count == 0)
	{
		DOpus.Output(" (none)");
	}
	else
	{
		for (var eSel = new Enumerator(cmd.files); !eSel.atEnd(); eSel.moveNext())
		{
			DOpus.Output(" " + eSel.item().RealPath);
		}
	}
}

```

(This also works in the normal case where there is a source tab.)

---

<div class="post-metadata">

**Author:** ![cwm9](https://resource.dopus.com/letter_avatar_proxy/v4/letter/c/898d66/32.png) [@cwm9](https://resource.dopus.com/u/cwm9)\
**Post date:** [January 5, 2022, 5:23pm UTC](https://resource.dopus.com/t/how-do-i-iterate-through-items-right-click-drag-and-dropped-context-menu-items/40229/3 "2022-01-05T17:23:03Z")

</div>

Great! Thank you. Works perfectly.

For anyone else needing a vbScript version:

```vbscript
for each item in cmd.files
   msgbox item.name
   msgbox item.path
   msgbox cmd.dest
next

```
