Copy music metadata to clipboard

I see that we have the option to copy file names (for example with Clipboard COPYNAMES=nopaths). Is there an easy way to copy the metadata of a music file? In particular the track length?

I know similar questions have been asked before, but no real example as been provided and I would love some clarification if possible.

Of just one file? Hover over it until the infotip appears, then push Ctrl + Shift + C to copy the information in the infotip to the clipboard.

This will copy mp3songlength of all selected files into the clipboard. Values will be in seconds.

function OnClick(clickData) {
    var tab = clickData.func.sourcetab;

    var result = '';

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        var tmp = item.metadata.audio.mp3songlength;
        if (typeof tmp == 'undefined') continue;
        result += tmp + '\n';
    }

    if (result == '') return;

    DOpus.SetClip(result);
}

Song Length.dcf (1.2 KB)


1 Like

I was actually thinking about multiple files, but that is a great tip! I didn't know you could do that :astonished:

Thanks!

I am not very script savy, but I assume we can use all keywords?

Now I will just have to find a way to make it display the duration as minutes:seconds. But this helps a lot to get started.

By the way, now that I think of it, it would be really cool to be able to save "Print Folder Contets" presets. Think of it as a feature request :wink:

What is the actual command to do that ? Because this shortkey is assigned to another action on my setup.

Plus, I have a script (made by you by the way) that display the shell product version. It can be accessed in tooltip by {scp:Shell Product Version/ShellProductVersion}. But how I get this value from a script ? I can not do better than item.metadata.exe.prodversion.

There isn't a command to copy the tooltip text to the clipboard. It's something that's hardcoded to Ctrl + Shift + C.

FSUtil.GetShellProperty or Item.ShellProp can be used to get shell property values within scripts. (Please start a new thread if you need more help with that.)

When I use this shortkey while the tooltip is displayed, it still applies the action assigned to it. In my case Clipboard COPYNAMES=unc. It’s not a big deal because I never intended to copy the tooltip before knowing this tip but it’s worth being mentioned.

Perfect. item.ShellProp("System.Software.ProductVersion"); work as intended.

We'll see if we can add a command which does the same thing, so it can be assigned to a different hotkey in this situation.

We'll add Clipboard COPYINFOTIP to do this in 12.25.1 beta (note: not 12.25, but the beta after it).

I also noticed that you can use Ctrl+Shift+Alt+C to trigger it at the moment. It's a bit of a pain to type, but serves as a temporary workaround.

We also have a couple of other small improvements to how this works, but I'll leave this for the eventual release notes in case the details change between now and then. Nothing too exciting though.

2 Likes