Renaming a file by specifying a name

Try

// https://resource.dopus.com/t/renaming-a-file-by-specifying-a-name/49356

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

    cmd.deselect = false;

    cmd.Clear();
    cmd.AddLine('Rename FROM="' + tab.all(1) + '" TO=Y002');
    cmd.AddLine('Rename FROM="' + tab.all(4) + '" TO=R005');
    cmd.AddLine('Rename FROM="' + tab.all(5) + '" TO=Z006');
    cmd.AddLine('Rename FROM="' + tab.all(6) + '" TO=L007');
    cmd.AddLine('Rename FROM="' + tab.all(7) + '" TO=H008');
    cmd.AddLine('Rename FROM="' + tab.all(9) + '" TO=F010');
    cmd.AddLine('Rename FROM="' + tab.all(10) + '" TO=L011');
    cmd.Run();
}
XML
<?xml version="1.0"?>
<button backcol="none" display="label" textcol="none">
	<label>49356</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/renaming-a-file-by-specifying-a-name/49356</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>	var cmd = clickData.func.command;</instruction>
		<instruction>	var tab = clickData.func.sourcetab;</instruction>
		<instruction />
		<instruction>    cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    cmd.Clear();</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(1) + &apos;&quot; TO=Y002&apos;);</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(4) + &apos;&quot; TO=R005&apos;);</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(5) + &apos;&quot; TO=Z006&apos;);</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(6) + &apos;&quot; TO=L007&apos;);</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(7) + &apos;&quot; TO=H008&apos;);</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(9) + &apos;&quot; TO=F010&apos;);</instruction>
		<instruction>    cmd.AddLine(&apos;Rename FROM=&quot;&apos; + tab.all(10) + &apos;&quot; TO=L011&apos;);</instruction>
		<instruction>    cmd.Run();</instruction>
		<instruction>}</instruction>
	</function>
</button>

How to use buttons and scripts from this forum

1 Like