Page 1 of 1

Script to copy DateCreated into DateTImeOrig needed

Posted: Fri Dec 14, 2012 5:27 am
by CaveMan
Hi,
I am looking for a script that copies the File Properties: DateCreated field into the Camera Data (Exif): Date Time Original field. I have a number of AVI fields that have the right information in the DateCreate (and the TIme Digitized Field which would be an alternate source) but have the Date Time Original field emtpy. I can copy/paste by hand but I have hundreds of files. The problem is that after encoding with MediaEncoder the information about the date seems to be lost unless the Date Time Original field is set. I have zero experience with Bridge Scripting so if anyone has a fragment that would get me close, that would be helpful. Alternatively if somebody on this board could put this together for me, I'd be happy to pay for a few hours. I've tried a lot of other tools but apart from cut/pasting in Bridge haven' t gotten anything to work.
Thanks much
Axel

Script to copy DateCreated into DateTImeOrig needed

Posted: Fri Dec 14, 2012 9:28 am
by Paul MR
This should update the exif field...

Code: Select all#target bridge   
   if( BridgeTalk.appName == "bridge" ) { 
dto  = MenuElement.create("command", "Update DateTimeOriginal", "at the end of Tools");
}
dto.onSelect = function () {
var sels = app.document.selections;
for(var a in sels){
    setDateTimeOriginal(sels[a].spec)
    }
};
function setDateTimeOriginal( file){
if ( !ExternalObject.AdobeXMPScript ) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
        var xmpf = new XMPFile( File(file).fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE );
        var xmp = xmpf.getXMP();
       var dc = xmp.getProperty(XMPConst.NS_PHOTOSHOP, 'DateCreated');
       if(dc != undefined){
        xmp.deleteProperty( XMPConst.NS_EXIF, 'DateTimeOriginal');
        xmp.setProperty(XMPConst.NS_EXIF, 'DateTimeOriginal', dc , XMPConst.XMPDATE);
      if (xmpf.canPutXMP( xmp )) {
         xmpf.putXMP( xmp );
      }
  }
      xmpf.closeFile( XMPConst.CLOSE_UPDATE_SAFELY );
};



Script to copy DateCreated into DateTImeOrig needed

Posted: Sat Dec 15, 2012 8:20 am
by CaveMan
Paul
Awesome. Thank you. I tested this on a JPG file and it works great. It seems to not work though for my .avi or .mp4 files? I don't see any errors but since I have no experience with the scripting in Bridge I am a bit a loss on how to start debugging this. Since I can do it by hand (cutting and pasting in Bridge) it cant really be a file protection issue but maybe the xmpf.canPutXMP method doesn't return the right value? I opened the script in the ExtendScript Editor and tried stepping through it but that doesn't yield any results.

Any suggestions?

Thanks much
Axel

Script to copy DateCreated into DateTImeOrig needed

Posted: Sat Dec 15, 2012 11:37 pm
by CaveMan
Ok. Figured it out: On the Video files (both MP4 and AVI) the date I wanted was hiding in the XMP "CreateDate" TAG.
After finding the dumpObject method in a sample snippet, I was able to figure it out

$.writeln(xmp.dumpObject());

; this was the change I needed
var dc = xmp.getProperty(XMPConst.NS_XMP, 'CreateDate');

Thanks again for the help: popped $50 into the Donation box.
Axel