Skip to main content
Antony_Mooe
Inspiring
November 14, 2017
Answered

Adding image Metadata from folder's name

  • November 14, 2017
  • 4 replies
  • 3286 views

Hello,

I have a folder with many images into and I'm need to add metadata (keyword) to the images from folder's name.

Ex: folder name: "lemon iced tea" / images keyword: "lemon iced tea".

I didn't find a way to do it.

Can anyone help me??

Thank you!

This topic has been closed for replies.
Correct answer SuperMerlin

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

folderTokeys = MenuElement.create("command", "Add Folder Name to Keywords", "at the end of Tools");

}

folderTokeys.onSelect  = function () {  

var thumbs = app.document.selections;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var FolderName =  decodeURI(Folder(app.document.presentationPath).name);

for(var a =0;a<thumbs.length;a++){

var selectedFile =  new Thumbnail(thumbs);   

app.synchronousMode = true;

var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());

xmp.appendArrayItem(XMPConst.NS_DC, "subject", FolderName, 0,XMPConst.PROP_IS_ARRAY);

var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

selectedFile.metadata = new Metadata(newPacket);

    }

};

Participant
March 8, 2018

Hello,

It's the script i need, but i am new in adobe bridge and i don't see where i can add this script and how i can run it ?

Can you please give me the steps  to use this script to adobe bridge

Thank's

Stephen Marsh
Community Expert
Community Expert
March 8, 2018

Once installed, the script Add Folder Name to Keywords will be available in the tools menu. Navigate into the folder and select the files, then select the menu command.

____________________

Prepression: Downloading and Installing Adobe Scripts

____________________

Saving JavaScript Source Code

Some scripts are offered as “source code”, rather than saved into a ready to use file. This is often the case with scripts found at the Adobe User Forums, GitHub, SourceForge etc. Simply select and copy/paste the script code into a plain text document, saving the file with a .jsx filename extension. Ensure that a double extension is not incorrectly added, such as .jsx.txt

NOTE: Only paste the source code into plain text editors, such as Notepad or Adobe ExtendScript Toolkit etc. Ensure that straight double-quote marks " do not become curly.

Adobe Bridge Script Installation Location

A quick way to locate the Startup Scripts folder:

  1. Open Adobe Bridge, then open Bridge’s preferences dialog
  2. Click the "Reveal My Startup Scripts" button
  3. Copy/Paste or drag-n-drop your .jsx script files into the folder/directory
  4. Quit and restart Bridge and answer "Yes" to enable the script.

Mac OS Example:

/Users/username/Library/Application Support/Adobe/Bridge CC 2018/Startup Scripts

Further information at the Adobe site:

https://helpx.adobe.com/bridge/using/adobe-bridge-workspace.html#enable_startup_scripts

Stephen Marsh
Community Expert
Community Expert
November 16, 2017

I always like to use these requests to learn to do the same in ExifTool (as it is more accessible to me than scripting):

exiftool -r '-Subject<${directory;s/\/$|\/|\d+|\w+\///g}' 'MAC FILE or FOLDER PATH'

I’m still trying to work out the command for Windows, the regex appears valid, but the entire path is still being incorrectly applied…

OK, here it is:

exiftool -r "-Subject<${directory;s/.+\/\b|\///g}" "WINDOWS FILE or FOLDER PATH"

There are no magic answers as folder paths can be complex and may break the regular expression, however the following code may be more robust than my previous attempts:

exiftool -r '-Subject<${directory;s/.*\/([^\/]*$)/$1/}' 'MAC FILE or FOLDER PATH'

exiftool -r "-Subject<${directory;s/.*\/([^\/]*$)/$1/}" "WIN FILE or FOLDER PATH"

Antony_Mooe
Inspiring
November 15, 2017

Hello SuperMerlin,

It works perfectly! Fantastic!!

Thank so much!

Cheers!!

SuperMerlin
SuperMerlinCorrect answer
Inspiring
November 15, 2017

#target bridge  

   if( BridgeTalk.appName == "bridge" ) { 

folderTokeys = MenuElement.create("command", "Add Folder Name to Keywords", "at the end of Tools");

}

folderTokeys.onSelect  = function () {  

var thumbs = app.document.selections;

if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");

var FolderName =  decodeURI(Folder(app.document.presentationPath).name);

for(var a =0;a<thumbs.length;a++){

var selectedFile =  new Thumbnail(thumbs);   

app.synchronousMode = true;

var xmp = new XMPMeta(selectedFile.synchronousMetadata.serialize());

xmp.appendArrayItem(XMPConst.NS_DC, "subject", FolderName, 0,XMPConst.PROP_IS_ARRAY);

var newPacket = xmp.serialize(XMPConst.SERIALIZE_USE_COMPACT_FORMAT);

selectedFile.metadata = new Metadata(newPacket);

    }

};

Participant
January 24, 2020

Hi SuperMerlin, this is just what I am looking for, However it does not seem to work with Adobe Bridge 2020. Would you know why this is and how I can modify the script to work with Bridge2020?

 

Thanks

Ron

Legend
January 24, 2020

This should still work. Where are you having problems? Note that presentationPath has some bugs and there are problems with certain special folders, but otherwise it should be fine.