Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding image Metadata from folder's name

Explorer ,
Nov 14, 2017 Nov 14, 2017

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!

TOPICS
Scripting
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Nov 15, 2017 Nov 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

...
Translate
Guide ,
Nov 15, 2017 Nov 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);

    }

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2020 Jan 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 24, 2020 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2020 Jan 27, 2020

Thank you so much for your response. Here is my current workflow. I have a 32 GB folder of product photos broken into many folders and subfolders, each folder named with a relevant product name or table of contents category name. The named folders are an ideal search paramenter when using a DAM (ResourceSpace). I was hoping to find a script that added the current parent folder (or folder name string) to either the metadata or keyword field, each name separated with a comma and space.

 

The script below does not seem to do a anything when implemented in Bridge 2020. I am not certain I am using it correctly. Should the script be applied to a folder or to selected group of images?

 

Thanks

Ron

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 27, 2020 Jan 27, 2020
LATEST
var thumbs = app.document.selections;

That means it is working on your selected images.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 15, 2017 Nov 15, 2017

Hello SuperMerlin,

It works perfectly! Fantastic!!

Thank so much!

Cheers!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2017 Nov 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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 08, 2018 Mar 08, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 08, 2018 Mar 08, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines