I have converted this to a user tool. The new note will be an octave up or octave down depending upon the prompt. See code for installation instructions. Modified to ignore "Fake" input when the selection starts in the middle of a measure.
/*
doOctave.js by Warren Porter
<PROMPT:Dir?:=|Up|Down>
Octave Tool
This tool will convert a note to an octave chord, replicating accidentals and tie status. The new note will be higher or lower
than the original note depending on the prompt.
This tool can operate on ONLY a selected part of a staff, or, if nothing has been selected, the entire staff.
To install:
1) Save this file with the name doOctave.js on your computer and remember its location.
2) Start NWC and press Alt/F8. Pick new
3) After choosing a name and group, browse for this file and click "Open".
4) Insert "wscript " at the beginning of the command and " <PROMPT:Dir?:=|Up|Down>" at the end.
5) Clip text should be selected and check no options.
*/
rc=0, errMsg="";
function doUp(clip) {
var displ=0, upDispl=0;
var result = new Array();
var lines = clip.split("\r\n");
for (i = 1; i < lines.length; i++) { // Main processing loop
if (/Fake/.test(lines[i]))
lines[i] = "#";
else {
result = lines[i].match(/(\|Note.*Pos:)([n#bvx]?)(-?\d+)(\^?)(.*)$/) // 1. Note thru Pos 2. Accidental 3. Position 4. Ties 5. To end of line
if (result != null) {
var note_lit = result[1];
var acc_lit = result[2]
displ = parseInt(result[3]);
var a_tie = result[4]
var eol = result[5]
note_lit = note_lit.replace("Note","Chord")
upDispl = displ + 7;
lines[i] = note_lit + acc_lit + displ + a_tie + "," + acc_lit + upDispl + a_tie + eol; }
} } // End main loop
return lines;
}
function doDown(clip) {
var displ=0, dnDispl=0;
var result = new Array();
var lines = clip.split("\r\n");
for (i = 1; i < lines.length; i++) { // Main processing loop
if (/Fake/.test(lines[i]))
lines[i] = "#";
else {
result = lines[i].match(/(\|Note.*Pos:)([n#bvx]?)(-?\d+)(\^?)(.*)$/) // 1. Note thru Pos 2. Accidental 3. Position 4. Ties 5. To end of line
if (result != null) {
var note_lit = result[1];
var acc_lit = result[2]
displ = parseInt(result[3]);
var a_tie = result[4]
var eol = result[5]
note_lit = note_lit.replace("Note","Chord")
dnDispl = displ - 7;
lines[i] = note_lit + acc_lit + dnDispl + a_tie + "," + acc_lit + displ + a_tie + eol; }
} } // End main loop
return lines;
}
var myLines;
if (WScript.Arguments.length != 1) {
errMsg="NO Prompt read.";
rc=1; }
else {
if (WScript.Arguments.Item(0).slice(0,2) == "Up")
myLines=doUp(WScript.StdIn.ReadAll()).join("\r\n");
else
myLines=doDown(WScript.StdIn.ReadAll()).join("\r\n"); }
if (rc == 0)
WScript.StdOut.Write(myLines);
else
WScript.StdErr.Write(errMsg);
WScript.quit(rc);