Skip to main content
shashi88
Participant
April 9, 2016
Question

Need a script to update keywords for 20000 images in Bridge

  • April 9, 2016
  • 3 replies
  • 5477 views

I have an excel with filename in column A and keywords in column B. I wish to update the keywords tab in bridge using a script. Please let me know if there is any pre written script available which I can use.

This topic has been closed for replies.

3 replies

Stephen Marsh
Community Expert
Community Expert
April 14, 2016
Stephen Marsh
Community Expert
Community Expert
April 9, 2016

If you don’t use the Bridge script, then I can help with ExifTool (both methods have their pros/cons).

shashi88
shashi88Author
Participant
April 9, 2016

Hi Stephen. Thanks for the quick reply. I would be more than happy if you could guide me with Exiftool.

I have downloaded the tool. All I need is to now how to use it.

Link to the excel file:

Dropbox - Workbook1.xlsx

Tanks in advance.

Stephen Marsh
Community Expert
Community Expert
April 11, 2016

I am on windows. As for the images, all are in a single parent directory plus the format is JPG.


You may wish to try DIY Metadata again adjusting your source .csv file as SuperMerlin noted


______________


As ExifTool is command line interface based and not GUI, you may prefer to use the Bridge script option!

USING EXIFTOOL – PART A:


Before using ExifTool, one should backup all files first. By default ExifTool will create duplicate files, leaving the original files untouched but renamed for safety. So you may need at least double the free hard drive space available as the images being processed. If you have backed up your files, then you could skip the part where files are duplicated for safety.

I also recommend duping a small amount of files to a test directory, then testing that everything works in this test folder, before running on a large batch of images.

Just as there are specific file input requirements for the DIY Metadata script, ExifTool also has requirements of how import data should be formatted…

Firstly, let’s use ExifTool to recursively export the source filename and file system path and the keywords to CSV, in order to ascertain what format is required for the input CSV file (the example below is using Windows OS formatting). I created a test folder and sub-folder with files that were keyworded in order to “reverse engineer” the required info.

Run the Windows Command Prompt and enter the following data (be careful of copy/paste as it can change characters such as straight inch to curly double quote marks). Note that ‘Currentuser’ needs to be replaced with the username of Windows account user that is currently logged in (I have syntax highlighted the CLI code below to help break it up visually into it’s components):

exiftool -csv -r -subject "C:\Users\Currentuser\Desktop\test" > "C:\Users\Currentuser\Desktop\test\meta out.csv"

ExifTool will recursively scan the images found in the desktop folder titled ‘test’ Which returns a .csv file titled ‘meta out.csv’ inside the folder ‘test’ on the desktop of the current logged in user.

The contents of the ‘meta out.csv’ file reads as:

SourceFile,Subject

C:/Users/Currentuser/Desktop/test/META 1.jpg,"keyword1, keyword-A"

C:/Users/Currentuser/Desktop/test/META-2.jpg,keyword2

C:/Users/Currentuser/Desktop/test/sub_folder/META_3.jpg,subject3

What does this mean in relation to our input spreadsheet .CSV file?

  1. We need specific column headers titled ‘SourceFile’ and 'Subject'.
  2. We need both an absolute source path and source filename in our .csv file.
  3. The separator for a .csv file should be a comma.
  4. If there are multiple keywords, they need to be enclosed within inch marks using a comma separator.

We will now need to format our import file to suit these requirements. In your particular case, if “63679573” is the filename and the format is JPEG, you will need to add both the file path prefix and the file extension suffix to the name. If you need help in adding the file path prefix or the filename extension suffix of .jpg to your existing filenames, then it is easy enough to do so using a spreadsheet formula, or a regular expression capable text editor or even with textmechanic.com (the same is also true for enclosing your existing keywords with inch marks at the start/end).

If you need help with this text manipulation, let the forum know.

You can upload another sample file to dropbox when you have edited it if you like.

Let the forum know when you are ready to move onto the next stage of using ExifTool…

SuperMerlin
Inspiring
April 9, 2016

If you save the Excel to CSV you could use. DIY Metadata

Another solution  would be to use Exiftool ExifTool by Phil Harvey

shashi88
shashi88Author
Participant
April 9, 2016

Tried to use DIY Metadata but when it execute it I get an error message saying the file doesnt exist. Is it because of the format in which the data is stored in CSV file?

SuperMerlin
Inspiring
April 9, 2016

The filename should be in the first column I.E. filename.jpg and the file should exist in the selected folder or a sub folder if the relevant checkbox is ticked.