Copy link to clipboard
Copied
Hi all
I stumbled across this script from Paul Riggott. It copies the file name to the Title field. Tested it and it works like a charm. So far so good.
I need the filename to be inserted into the "Creator: Job Title" field. I haven't written a line of code in my life, but I tried to replace all instances of "title" (case sensitive) with "photoshop:AuthorsPosition"... Should have known it didn't work.
Any help would be greatly appreciated!
Kind regards
/Henrik
#target bridge | ||
if( BridgeTalk.appName == "bridge" ) { | ||
FAP = MenuElement.create("command", "Add FileName to Author Position", "at the end of Tools"); | ||
} | ||
FAP.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.spec; | ||
var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '') | ||
Copy link to clipboard
Copied
#target bridge | ||
if( BridgeTalk.appName == "bridge" ) { | ||
FAP = MenuElement.create("command", "Add FileName to Author Position", "at the end of Tools"); | ||
} | ||
FAP.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.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_PHOTOSHOP, "AuthorsPosition"); | ||
myXmp.setProperty(XMPConst.NS_PHOTOSHOP, "AuthorsPosition", Title); | ||
if (myXmpFile.canPutXMP(myXmp)) { | ||
myXmpFile.putXMP(myXmp); | ||
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY); | ||
} | ||
} | ||
}; |
Copy link to clipboard
Copied
Hi SuperMerlin.
Wow. Just wow! It works perfectly. You really saved my day.
Hope I can return the favor some day!
Thanks!
Kind regards
/Henrik
Copy link to clipboard
Copied
Hi SuperMerlin
I have a little follow-up question: Is it possible to include the file extension?
Thanks in advance.
Kind regards
/Henrik
Copy link to clipboard
Copied
Yes
Change:
var Title = decodeURI(selectedFile.name).replace(/\.[^\.]+$/, '')
To
var Title = decodeURI(selectedFile.name);
Best of luck.
Copy link to clipboard
Copied
Damn, you're fast!
Thanks a lot!
Kind regards
/Henrik
Copy link to clipboard
Copied
For completeness, the equivalent ExifTool command would be as follows...
Without Extension:
exiftool '-XMP-photoshop:AuthorsPosition<${filename;s/\.[^.]*$//}' -r 'Path to Folder or File'
With Extension:
exiftool '-XMP-photoshop:AuthorsPosition<${filename}' -r 'Path to Folder or File'
NOTE: These commands are formatted for the Mac OS, Windows OS uses double straight " quote marks.