Button to Update File Creation Dates Using ExifTool w/Logic for Video or Image File

I want to create a button to:

  1. change the FileCreateDate to EXIF:CreateDate if the selected file is an image file (EXIF:CreateDate not empty) OR change the FileCreateDate to QuickTime:CreationDate if the selected file is a video file (QuickTime:CreationDate not empty). I have created standard function buttons (one for video and one for image files).
    //Image file
    exiftool -overwrite_original "-FileCreateDate<EXIF:CreateDate" -@ {allfilepath|filem}
    //Video file
    exiftool.exe -overwrite_original "-QuickTime:CreateDate<QuickTime:CreationDate" "-FileCreateDate<QuickTime:CreationDate" -@ {allfilepath|filem}
  2. Rename the file to include the FileCreateDate. I created a rename command for this.
    RegEx: DPC_{created|D#yyyyMMdd_T#HHmmss}_\1
    I have tried to create Jscript for a button to do these tasks in a single button. I am struggling and could use some help.

It'll be much easier and faster to let ExifTool check the tags, e.g.:

@nodeselect

exiftool.exe -if "$EXIF:CreateDate"        "-FileCreateDate<EXIF:CreateDate"                                                       -overwrite_original -@ {allfilepath|filem}
exiftool.exe -if "$QuickTime:CreationDate" "-FileCreateDate<QuickTime:CreationDate" "-QuickTime:CreateDate<QuickTime:CreationDate" -overwrite_original -@ {allfilepath|filem}

Rename TO=DPC_{created|D#yyyyMMdd_T#HHmmss} IGNOREEXT AUTONUMBER
1 Like

Thank you.

I want to grab the file number from the original file name and append to the new file name.

Old Name: ([0-9]+)(.*)#
New Name: DPC_{created|D#yyyyMMdd_T#HHmmss}_\1

Rename PATTERN=([0-9]+)(.*)# TO=DPC_{created|D#yyyyMMdd_T#HHmmss}_\1 REGEXP IGNOREEXT AUTONUMBER

Perfect. Thank you. I want to learn how to write code for buttons. Are there any tutorials you recommend?

Well, this topic was more about ExifTool than it was about Opus :wink:

The Tutorials section is your best start. Watch the videos, even the old ones for Opus 12 are packed with relevant info. The forum is full of solutions, grab the ones you like and start modifying them for your specific use case.

Following the guidelines here makes life easier for everyone.