Closed FunctionDJ closed 2 years ago
Well it must be Delete File
for a handle or handle list with a count of 1 and Delete Files
for a handle list with multiple handles. If you really meant that, don't write Delete file(s)
because that's obviously wrong/misleading to anyone reading.
Also, the return value it not based on the success of the command. It's whether the command exists. And if the dialogs/operations are asynchronous, the function will return immediately anyway. Taking it to the extreme, it could be minutes/hours before whatever action is finished.
Anyway, you might find it easier to use FileSystemObject.
Thanks for the advice! I just used the name that i saw in the Keyboard Shortcuts settings. Using the variations you mentioned makes a lot more sense, but i don't know where they are listed. Also really good to know about the async behaviour. I'll probably end up using FSO like you recommended.
I appears that fb.RunContextCommandWithMetadb("Delete files", fb.GetSelections())
only works when more than 1 track is selected, even though the result of GetSelections()
is always a handle list.
If you check marc answer, the menu changes to Delete file whenever the list only has 1 handle. The menu is related to the handle count, not to the object prototype used. So that's not a bug but intended behavior, since the menu is created outside SMP context. Anyway you can bypass that limitation with a bit of code:
const handleList = fb.GetSelections();
fb.RunContextCommandWithMetadb(handleList.Count > 1 ? "Delete files" : "Delete file", handleList)
@regorxxx that's basically what i wrote already :D i wasn't sure that these command names are literally taken from the available context menu, that's good to know. for some reason i thought it was just something that grew historically or something like that. thanks!
Yep it's a bit counterintuitive on first thought. But since the menus are created by the main program.... have that in mind in your other use-cases, it can only use whatever is there for the selection (not sure if that's related in any way to your "play" error).
I'm trying to run
fb.RunContextCommandWithMetadb("Delete file(s)", handle)
but it always fails (returnsfalse
). Am i doing something wrong? I tried both with a handle list and a single handle.