Copy link to clipboard
Copied
Does someone have a script to add "Copy File Name without extension" (and without path) to the clipboard in the context menu?
I already have "copy full name and path" and "copy name with extension." I've tried to edit them but can't figure it out.
Thanks,
Drew
Copy link to clipboard
Copied
Are you using CS6 and windows7?
Copy link to clipboard
Copied
At least on CS6 it works.
// Adapted from bridge_CS6_SDK by
// Pedro Marques
// This will only add ContextMenuItem popup item if only 1 file is selected on Content and it does not work on Folders
//
function SnpAddContextMenuItem()
{
this.requiredContext = "\tAdobe Bridge must be running.\n\tExecute against Bridge CS6 as the Target.\n";
$.level = 1; // Debugging level
this.menuID = "FileNameToClipboard";
}
SnpAddContextMenuItem.prototype.run = function()
{
var retval = true;
if(!this.canRun()) {
retval = false;
return retval;
}
// create the menu element
var cntCommand = new MenuElement("command", "FileName only >> Clipboard", "before PurgeCacheForSelected-", this.menuID);
// What to do when the menu item is selected
cntCommand.onSelect = function(m)
{
if (m.text == "FileName only >> Clipboard") {
app.system("echo "+app.document.selections[0].name.replace(/\.[^\.]+$/, '').replace(/(?:\..+)/g,'')+"| clip.exe")
}
};
// When to display the menu item
cntCommand.onDisplay = function()
{
try
{
cntCommand.enabled = (app.document.selections.length == 1) ? true : false;
// Check if the thumbnail is a container
if(app.document.selections[0].container)
{
cntCommand.text = "Does not run with folders Folders";
}
else
{
cntCommand.text = "FileName only >> Clipboard";
}
}
catch(error){ $.writeln(error); }
};
return retval;
}
SnpAddContextMenuItem.prototype.canRun = function()
{
// Must run in Bridge
if(BridgeTalk.appName == "bridge")
{
// Stop the menu element from being added again if the snippet has already run
if(MenuElement.find(this.menuID))
{
$.writeln("ERROR:: Menu element from FileNameToClipboard already exists!\nRestart Bridge to run this snippet again.");
return false;
}
return true;
}
// Fail if these preconditions are not met. Bridge must be running, The menu must not already exist.
$.writeln("ERROR:: Cannot run FileNameToClipboard");
$.writeln(this.requiredContext);
return false;
}
if(typeof(SnpAddContextMenuItem_unitTest) == "undefined") {
new SnpAddContextMenuItem().run();
}