Copy DateCreated from master to version

Started by stahl, January 08, 2023, 07:06:15 PM

Previous topic - Next topic

stahl

Hello,
I am trying to write an app (my first in JavaScript) that will find the master of each selected file and will copy the master's DateCreated to the versions'.
I am having a hard time finding out how I can do this, starting with how I can access the DateCreated of a given file's master.

I tried the file relations sample app and the IMatch developer documentation already but don't seem to find the clues.

Would you have any suggestions or, possibly, code snippings?
Thanks!

Mario

What tag do you want to copy? What is the precise tag name?
The only standard tags in XMP are CreateDate and DateSubject created (see Metadata Panel).

Why not use propagation?

The File Relation sample app shows how to work with relations.
The Metadata sample app shows how to read metadata and how to modify metadata.
If you know which tag you actually want to copy, you can read it from the master and write it to the version. The Metadata App shows how to do this.


-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

stahl

Hello Mario,
thanks für your quick response.
The tag I want to have copied over from the master to the selected version is "XMP::photoshop\DateCreated\DateCreated\0".

I'd be happy to use propagation, it seems to me though that I can run a propagation neither just on this tag, nor just on the selected files nor starting from a version in focus nor could I just click somewhere to have it running, but I would have to change the propagation preferences back and forth every time. Or don't I?

Maybe I am really thick here, but don't seem to find how the Metadata App gives an example of how to copy from another file, not from the very file itself. From the File Relation Sample App I get the impression that probably versionState and type:'versions' seem to be crucial, but I fail to find them in the documentation, same as "master" yields no hits there. Nor does "v1/get/files" that has been mentioned in another thread here.

If you could point me in the right direction, that'd be great!

Mario

#3
This is how I would do it. Please understand that I cannot write custom apps or provide extended support.

for each selected file, determine if it a version
  for each version, find the master
    if a master is found, fetch the tag value with v1/files
      use v1/metadata to update the tag in the version

Search for #btn-increment-rating in the Metadata Sample. This method fetches the rating for a file, increments it and writes it back. The only difference in your app would be that you fetch the data for the master and write it back to the version, not fetch and write back to the same file.

For example, here is a a small code fragment to get all selected files in the File Window and determine if they are versions:

const selectedFiles = await IMWS.get('v1/files', {
    idlist: IMatch.idlist.fileWindowSelection,
    fields: 'id,versionstate'
});

let versionIds = [];
selectedFiles.files.forEach(f => {
    console.log(`[${f.id}] {${f.versionState & 2 ? 'version' : 'no version'}}`);
    if (f.versionState & 2) {
        versionIds.push(f.id);
    }
});
console.log(`${versionIds.length} versions selected.`);

You would then use versionIds to find the masters for each version, fetch the tag value for each master with v1/files and store the tag value for each version with v1/metadata.

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

thrinn

Quote from: stahl on January 08, 2023, 10:26:35 PMFrom the File Relation Sample App I get the impression that probably versionState and type:'versions' seem to be crucial, but I fail to find them in the documentation, same as "master" yields no hits there. Nor does "v1/get/files" that has been mentioned in another thread here.
If you are looking for details on specific endpoints (e.g. "v1/files"), use the inbuilt IMWS documentation. You can access it either via the IMWS DevDocs App,
2023-01-09 10_59_41-IM2020 Pictures.imd5.jpg

or by using this link in a browser. Note that IMatch must be running and that you might have to change the port (50519) to the one you configured.
http://127.0.0.1:50519/imatch/apps/imws-doc/index.html
If you have not worked with the DevDocs before, just some tips:
  • When using the search field at the top, skip the "v1" part. For example, search for "files", not for "v1/files".
  • You provided "v1/get/files" as an example. For finding this in the DevDocs, enter "files" into the seach field. The "get" is not part of the endpoint, it is the HTTP method.The "v1" is indeed part of the endpoint name, but as mentioned above, don't use it in the search fields.
2023-01-09 11_06_52-IMatch WebServices Documentation – Mozilla Firefox.jpg  
Thorsten
Win 10 / 64, IMatch 2018, IMA

stahl

Many thanks to both of you, Mario and thrinn! This is really useful information.
It is greatly appreciated!

Jingo

I also suggest scouring through all the provided apps (the older ones non-compiled ones included in IMatch) as well as the user apps listed in the APPs forum for hints/tricks and code examples.  When I started writing apps, these were invaluable to learning as well as "borrowing" code to get started.

If I can offer any assistance, please feel free to let me know! - Andy.

Mario

QuoteI also suggest scouring through all the provided apps (the older ones non-compiled ones
I keep the sample apps in plain JavaScript / HTML exactly for this purpose. Also the majority of the standard apps shipped with IMatch are in plain JS/HTML and commented.

For more integrated and more powerful apps like the Event View, Dashboard etc. I need better tooling for efficient work, different "not really beginner friendly" frameworks and an I use an entirely different workflow. Which also produces more efficient, smaller and compiled apps as an end result.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook