Answered
bridge script failing when added as menu item
The following script will not run in when wrapped in a menu item. But the main function runs fine on its own...
Any idea whats going on.
#target bridge
var menu = MenuElement.create( "command", "Anon_forSending", "at the end of Tools");
menu.onSelect = function(m) { main() }
function main(){
var selectedThumbnails = app.documents[0].getSelection();
var modified = 0;
for (var i = 0; i < selectedThumbnails.length; ++i) {
var val = decodeURI(selectedThumbnails[i].name);
var f = new File (decodeURI(selectedThumbnails[i].path))
if (stripFileExtension)
val = val.replace(/\.[^\.]+$/, '');
p = (val.match(/_0/).index)+1
val =val.substr(p,4)
newName = val + '.psd'
var f1 = new File (f.parent + "/" + newName)
if (f1.exists == true){newName = val + '_1' + '.psd'}
var metadata = selectedThumbnails[i].synchronousMetadata;
metadata.namespace = 'http://ns.adobe.com/photoshop/1.0/';
metadata.applyMetadataTemplate("clearall", "replace")
selectedThumbnails[i].name = newName
}
}
