Copy link to clipboard
Copied
I have previously used John Beardsworth's script Set Filename to Metadata which put the file name in the Document Title in File Information. In Bridge 2020 under Tools, it is not showing up. I can see the script in the BridgeStartup list. Is just isn't available. I just discovered this as I haven't used Photoshop for a while.
Has anyone else experienced this problem?
I have emailed John about this.
Any help with this would be greatly appreciated. It is a great little script.
Copy link to clipboard
Copied
Can you share the link to the script download or paste the code?
Sometimes the script menu name is not the same as the script file. Most scripts are under the tools menu, however some are contextual right click.
What metadata field/s is the filename being written to?
Copy link to clipboard
Copied
Set filename to metadata CS2-CS5.zip
The script copies the image file name to the IPTC Document Title.
I tried resetting bridge preferences, but that did not fix the problem.
Right click does not show the option.
Copy link to clipboard
Copied
John has replied with the answer that something broke the script. I've asked him if he is possibly thinking about fixing the script.
It was a very simple and very effective tool which I have used for many years now, so I would really hate to lose it.
Copy link to clipboard
Copied
The script still appears to work in CC2019 for what that is worth:
There are a few different options in the script, as shown in the screenshot above.
It is easy enough to modify alternative scripts to include the filename extension and there are other scripts to set and clear the preserved filename metadata.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Another option:
//imagesimple.wordpress.com/2011/08/24/cs5-filename-to-title-script/
#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Add FileName to Title", "at the end of Tools");
}
FT.onSelect = function () {
AddFilenameToTitle();
}
function AddFilenameToTitle(){
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new
ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN,
XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
myXmp.deleteProperty(XMPConst.NS_DC, "title");
myXmp.appendArrayItem(XMPConst.NS_DC, "title", Title, 0,
XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "title[1]",
"http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
And another, modified from adding the filename to description:
//forums.adobe.com/message/10061534#10061534
//forums.adobe.com/message/3595421#3595421
#target bridge
if( BridgeTalk.appName == "bridge" ) {
fileToDesc = MenuElement.create("command", "Add FileName to Title", "at the end of Tools");
}
fileToDesc.onSelect = function () {
var thumbs = app.document.selections;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a =0;a<thumbs.length;a++){
var selectedFile = new Thumbnail(thumbs[a]);
app.synchronousMode = true;
var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());
var Desc = getArrayItems(XMPConst.NS_DC, "title");
if(Desc != "") Desc+= ";";
xmp.deleteProperty(XMPConst.NS_DC, "title");
xmp.setLocalizedText( XMPConst.NS_DC, "title", null, "x-default", Desc += decodeURI(selectedFile.spec.name).replace(/\..+$/,""));
var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
selectedFile.metadata = new Metadata(newPacket);
}
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = xmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(xmp.getArrayItem(ns, prop, i));
}
return arrItem.toString();
}catch(e){alert(e +" Line: "+ e.line);}
}
};
Copy link to clipboard
Copied
How do I go about adding this filename to description script? Do I edit the FilenametoTitle script or create a new one?
Copy link to clipboard
Copied
You can edit it if you like. I'll post the original script code for description as this is for title.
Copy link to clipboard
Copied
Here is one:
// https://forums.adobe.com/thread/2009311
// https://forums.adobe.com/message/10537059#10537059
#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Add FileName Prefix to Description", "at the end of Tools");
}
FT.onSelect = function () {
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
var FileName = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var Desc=[];
var count = myXmp.countArrayItems(XMPConst.NS_DC, "description");
for(var i = 1;i <= count;i++){
Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i));
}
Desc=FileName.toString() + " " + Desc;
myXmp.deleteProperty(XMPConst.NS_DC, "description");
myXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
And another one:
// https://forums.adobe.com/message/10061534#10061534
// https://forums.adobe.com/message/3595421#3595421
#target bridge
if( BridgeTalk.appName == "bridge" ) {
fileToDesc = MenuElement.create("command", "Add FileName to Description", "at the end of Tools");
}
fileToDesc.onSelect = function () {
var thumbs = app.document.selections;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a =0;a<thumbs.length;a++){
var selectedFile = new Thumbnail(thumbs[a]);
app.synchronousMode = true;
var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());
var Desc = getArrayItems(XMPConst.NS_DC, "description");
if(Desc != "") Desc+= ";";
xmp.deleteProperty(XMPConst.NS_DC, "description");
xmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc += decodeURI(selectedFile.spec.name).replace(/\..+$/,""));
var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
selectedFile.metadata = new Metadata(newPacket);
}
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = xmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(xmp.getArrayItem(ns, prop, i));
}
return arrItem.toString();
}catch(e){alert(e +" Line: "+ e.line);}
}
};
And one more:
// https://forums.adobe.com/thread/2009311
#target bridge
if( BridgeTalk.appName == "bridge" ) {
FT = MenuElement.create("command", "Add FileName to Description", "at the end of Tools");
}
FT.onSelect = function () {
var thumbs = app.document.selections;
if(!thumbs.length) return;
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
for(var a in thumbs){
var selectedFile = thumbs[a].spec;
var FileName = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var Desc=[];
var count = myXmp.countArrayItems(XMPConst.NS_DC, "description");
for(var i = 1;i <= count;i++){
Desc.push(myXmp.getArrayItem(XMPConst.NS_DC, "description", i));
}
Desc=Desc.toString() + " " + FileName;
myXmp.deleteProperty(XMPConst.NS_DC, "description");
myXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0, XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "description[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
}
Not sure about this one:
#target bridge
// https://forums.adobe.com/message/10537060#10537060
prefixNametoDescMeta = {};
prefixNametoDescMeta.execute = function(){
var sels = app.document.selections;
for (var i = 0; i < sels.length; i++){
var md = sels[i].synchronousMetadata;
md.namespace = "http://ns.adobe.com/photoshop/1.0/";
var Name = decodeURI(sels[i].name).replace(/\.[^\.]+$/, '');
md.Caption = Name + " " + md.Caption;
}
}
if (BridgeTalk.appName == "bridge"){
var menu = MenuElement.create( "command", "Prefix Filename to Description Metadata", "at the end of Tools");
menu.onSelect = prefixNametoDescMeta.execute;
}
Downloading and Installing Adobe Scripts
Copy link to clipboard
Copied
Stephen - These are SO helpful, thanks! I'll give it a try.
Copy link to clipboard
Copied
And for completeness, here is the ExifTool command to copy the filename to the Title metadata field, without the extension:
exiftool -overwrite_original '-title<${filename;s/\.[^.]*$//}' 'fileORdirectory'
Note: This command is formatted for the Mac, Win users would replace the single straight quotes with double straight quotes. The 'fileORdirectory' would be replaced with the full file system path to the file or folder to process. Further arguments can be added to recurse into all sub-directories under the top level folder, include or exclude specific file types or folders etc.
Copy link to clipboard
Copied
OK. What you show for 2019 is exactly what I had. But, I do not have it with 2020.
Also, I just simply cannot figure out how to install the first alternative you list. I have printed out the help pdf for the Utility Script Pack 2.1 for Bridge. I have been able to download the utility pack, but I simply cannot figure out how to install it. I did a copy and paste into the startup script fold for Bridge 2020, but nothing shows up. I closed Bridge, restarted it, and did not see the start script in the preferences.
I must be doing something wrong.
Copy link to clipboard
Copied
I was finally able to figure out how to install the script. I was able to set the file name to the document title.
Is there any way to include the file extension?
Copy link to clipboard
Copied
My generic reply would be:
Downloading and Installing Adobe Scripts
However I'll double check the instructions for dependencies or limitations.
Copy link to clipboard
Copied
If you could help me out, that would be great. You must have figured out by now that I no nothing about workings with scripts, so your link about was very difficult to understand.
BTW, you have helped me out in the past, so thanks again.
Lynnea
Copy link to clipboard
Copied
This modified code retains the original full filename including extension and does not split on the hyphen as the orginal code did. Replace the original FilenametoTitle.jsx file with the code below as per the instructions for saving copied code to plain text file with .jsx extension / Downloading and Installing Adobe Scripts / or just copy/paste this code replacing all of the original code into the existing FilenametoTitle.jsx file in your Startup Scripts folder and quit/restart Bridge:
/**
* @@@BUILDINFO@@@ FilenametoTitle.jsx !Version! Tue Nov 26 2019 09:07:36 GMT-0500
*/
/*
Utility Pack Scripts created by David M. Converse ©2018-19
Writes filename to Title metadata field.
/* Modified 30 March 2020 by Stephen Marsh to retain original filename in full */
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
try{
var FilenametoTitle = new Object; //id object for this script
#include "prefsReader.jsxinc" //shared prefs read code
//create menu
if(useMenu == true){ //use Tools submenu
if(MenuElement.find('utilPack') == null){ //submenu not yet created
MenuElement.create('menu', 'Utility Script Pack', 'at the end of Tools', 'utilPack');
}
var ftCmd = MenuElement.create('command', 'Filename to Title', 'at the end of utilPack');
}
else{ //do not use submenu
var ftCmd = MenuElement.create('command', 'Filename to Title', 'at the end of Tools');
}
if(useCMenu == true){ //use contextual submenu
if(MenuElement.find('cutilPack') == null){
MenuElement.create('menu', 'Utility Script Pack', 'after Thumbnail/Open', 'cutilPack');
}
var ftContCmd = MenuElement.create('command', 'Filename to Title', 'at the end of cutilPack'); //add to Contextual menu
}
else{ //do not use contextual submenu
var ftContCmd = MenuElement.create('command', 'Filename to Title', 'after Thumbnail/Open', this.menuID); //add to Contextual menu
}
}
catch(e){
//alert(e + e.line);
}
}
ftCmd.onSelect = function(){
ftAddFilenameToTitle();
}
ftContCmd.onSelect = function(){
ftAddFilenameToTitle();
}
function ftAddFilenameToTitle(){
try{
var ftThumbs = app.document.selections; //get selected thumbnails
if (!ftThumbs.length) return; //nothing selected
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
for(var a in ftThumbs){ //loop through thumbs
var ftTitle = ftThumbs[a].name; //get filename
//remove filename after last dash character
//to retain filename after dash, comment out lines 69-73
//ftTitle = ftTitle.split('-');
//if(ftTitle.length > 1){
// ftTitle.length--;
// }
//ftTitle = ftTitle.join('-');
//remove filename after last period character
//ftTitle = ftTitle.split('.');
//if(ftTitle.length > 1){
// ftTitle.length--;
// }
//ftTitle = ftTitle.join('.');
var ftMeta = ftThumbs[a].synchronousMetadata;
var ftXMP = new XMPMeta(ftMeta.serialize());
ftXMP.deleteProperty(XMPConst.NS_DC, 'title'); //delete old title
ftXMP.appendArrayItem(XMPConst.NS_DC, 'title', ftTitle, 0, XMPConst.ALIAS_TO_ALT_TEXT); //write new title
ftXMP.setQualifier(XMPConst.NS_DC, 'title[1]', 'http://www.w3.org/XML/1998/namespace', 'lang', 'x-default');
var ftUpdatedPacket = ftXMP.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
ftThumbs[a].metadata = new Metadata(ftUpdatedPacket); //write to file
}
}
catch(e){
//alert(e + e.line);
}
}
Copy link to clipboard
Copied
So, if I select the code, copy, then paste it in the Bridge startups script, this should retain the full file name plus the extension in the Documents Title?
Where do I start the copy code? Do I start here?
*/ #target bridge
What I want is this: 2019-09-21-_MG_0747.CR2
What I got was 2019-09-21
Will I be able to see this option under Tools in Bridge?
Copy link to clipboard
Copied
Start from the top line, here the first two and the last three lines are shown:
/**
* @@@BUILDINFO@@@
// The rest of the code here...
catch(e){
//alert(e + e.line);
}
}
This should give you a text file with 95 lines, 398 words, 4001 characters. You do need to open the original script into say notepad.exe or a plain text editor, paste in the copied code and save the file again. Quit and restart Bridge.
Everything else is the same, except for the modified code and the full filename+extension result.
That is why I posted the updated code, the original removed the filename extension and split on the first hyphen found in the name.
Here is the result from Bridge 2020 using the modified script code on one of my CR2 files that I renamed to match your example:
Copy link to clipboard
Copied
Just checking that I understand the directions. The Startup Scripts has this folder: Utility Script Pack. I should remove this folder.
Do I create a new folder in the Startup Scripts, then copy and paste the code using notepad.exe. Save the file.
Just by closing after copy and paste, does this save the file?
Quit the Startup Scripts, and restart Bridge.
Copy link to clipboard
Copied
1. Keep the utility script folder and all of it's files as they currently are...
2 Go inside this folder and open the filenametotitle.jsx into a plain text editor program (not ms word or wordpad, just notepad).
3. Delete all existing code. Paste in the copied script code, save and close (or close and save).
4. Restart Bridge and test.
Copy link to clipboard
Copied
I am unable to make this work. There is an error message which I have been able to save with a screen print, but I cannot figure out how to add it to this reply. The text says it may not be compatible with this version of bridge. Now the whole Filename to Title option is missing. If I enable it in preferences, startup scripts. the whole utility pack disappears.
Copy link to clipboard
Copied
Hi Stephen,
I'll try again later in the day. It seems that it takes me more than two tries to get things working.