Hi Leo,
in this item :
How to open a shortcut(.lnk) from a command - #10 by Leo
you mentioned that
No filename code, but scripts can look up shortcut targets, fwiw
I'm trying to create a column-script that will
- return a shortcut's link if that is the file extension
- and the file's path if the current tab is a collection
I've attached the script, inline, below. I was trying to use the ScriptColumnData.columns
object, perhaps erroneously, on line 68+1 of the script.
Could you pls provide a code snipped by which a script can return that information?
Many thx, Cheers, Brian
// jsFileHome
//
//
// This is a script for Directory Opus.
// See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information.
//
//
//
// The OnInit function is called by Directory Opus to initialize the script add-in
function OnInit(initData) {
// Provide basic information about the script by initializing the properties of the ScriptInitData object
initData.name = "nmFileHome";
initData.desc = "Adds a column that counts the length of the FullyQualified FileName.";
initData.copyright = "(c) 2016 Brian Moloney";
initData.default_enable = true;
// initData.multicol = true;
// Create a new ScriptColumn object and initialize it to add the column to Opus
var cmd = initData.AddColumn();
cmd.name = "nmFileHome";
cmd.method = "OnnmFileHome";
cmd.label = "nmFileHome";
cmd.autogroup = false; // we provide our own grouping information
cmd.autorefresh = true; // refresh column when files change
cmd.justify = "left";
//cmd.multicol = true;
cmd.match.push_back("Yes"); // when searching, these are the only two options
}
// Implement the IsModified column (this entry point is an OnScriptColumn event).
// The name of this function must correspond to the value specified for the method property when the column was added in OnInit
function OnnmFileHome(scriptColData)
{
// scriptColData is a ScriptColumnData object. first check that this is the right column (it should be since we only added one)
scriptColData.value = '<notSet_01>';
if (scriptColData.col != "nmFileHome")
{ return; }
scriptColData.value = '<notSet_02>';
var tabPath = new String(scriptColData.tab.path.longpath);
// DOpus.Output ('file dtl is ... ' + scriptColData.item.ext);
//Opus.Output ('file startOfPath is ... ' + tabPath.substring(0,7));
var soughtValue = new String('');
if (scriptColData.item.ext == '.lnk')
{ DOpus.Output ('file is .lnk');
DOpus.Output("count: " + scriptColData.item.columns.count);
/*
for (var e = new Enumerator(scriptColData.columns); !scriptColData.columns.atEnd(); scriptColData.columns.moveNext())
{
var key = e.item();
var value = map(key);
DOpus.Output(key + " -> " + value);
}
*/
// soughtValue = scriptColData.item.columns('Name').value; // 'sv'; //
soughtValue = scriptColData.columns('target').value; // 'sv'; //
scriptColData.value = soughtValue;
DOpus.Output ('file target is ... ' + scriptColData.value);
} else if (tabPath.substring(0,7) == 'coll://') // is a collection
{ // DOpus.Output ('file is in a coll://');
// DOpus.Output ('...' + scriptColData.item.realpath.longpath);
scriptColData.value = scriptColData.item.realpath.longpath;
}
scriptColData.group = scriptColData.value;
scriptColData.sort = scriptColData.value;
}