Rename folder based on mp3 tag of included files

Try

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    cmd.deselect = false;
    if (tab.selected_files.count == 0) return;
    var item = tab.selected_files(0);
    if (item.metadata != 'audio') return;
    cmd.RunCommand('Rename FROM="' + item.path + '" TO="' + item.metadata.audio.mp3album + ' (' + item.path.filepart + ')"');
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
	<label>37432</label>
	<icon1>#rename</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction>    if (tab.selected_files.count == 0) return;</instruction>
		<instruction>    var item = tab.selected_files(0);</instruction>
		<instruction>    if (item.metadata != &apos;audio&apos;) return;</instruction>
		<instruction>    cmd.RunCommand(&apos;Rename FROM=&quot;&apos; + item.path + &apos;&quot; TO=&quot;&apos; + item.metadata.audio.mp3album + &apos; (&apos; + item.path.filepart + &apos;)&quot;&apos;);</instruction>
		<instruction>}</instruction>
	</function>
</button>

2 Likes