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

get and set rating with JavaScript

Explorer ,
Feb 19, 2025 Feb 19, 2025

I am trying to get and set the rating (stars) of JPEG and RAW data with JavaScript, but I cannot find an interface to do this.

I already get the file name and other information. Is there any techniques?

 

 

#target bridge

var selectedItems = app.document.selections;
var currentFolder = null;
if (selectedItems.length > 0) {
    currentFolder = selectedItems[0].parent.path;
} else {
    currentFolder = "~/Pictures";
}

var d = Folder.selectDialog("select folder", currentFolder);
var f = d.getFiles();

for(var i = 0; i < f.length; i++){
    alert(f[i].name, f[i].rating); // rating is undefined
}

 

 

TOPICS
How to , Scripting
106
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
Enthusiast ,
Feb 19, 2025 Feb 19, 2025

You can't use files, you need to use thumbnails. RAW files don't have a rating. That info is stored in the XMP sidecar which is a separate file.

thumbs = app.document.selections;
for(var i = 0; i < thumbs.length; i++){
   thumbs[i].rating = 1;
   }
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 ,
Feb 19, 2025 Feb 19, 2025

Thanks. I misunderstood the implementation.

 

What I ultimately wanted to do was select two folders with the file dialog and copy the ratings in one folder to the other.
It is easy to do getFiles() from selectDialog(), but is it possible to access the thumbnails (or ratings) in a specific folder as well?

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
Enthusiast ,
Feb 19, 2025 Feb 19, 2025
LATEST

You would have to do matching of filenames, have you written that part?

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