File name to modified date/time?

Nevertheless, the script has worked flawlessly in my case. Thanks @Leo, appreciate it. :slight_smile:

1 Like

I see that the SetAttr internal commands are used in this script https://www.gpsoft.com.au/help/opus12/index.html#!Documents/SetAttr.htm

I was able to modify the script to write to the Standard Properties 'Date Created' field using 'CREATED' in place of 'MODIFIED'.

Video dates are a big problem in my line of work, and often the correct date is only in a filename or folder name. Is there a command argument to write the date from the filename to the Movie Properties 'Release Date' field? I have used Graphic Converter (for Mac only) for this task, but am looking for a Windows/PC solution.

:warning: This is not tested, so try it on some backup video files first in case I got something wrong.

This type of command should set the release date field on file types Opus knows how to do so:

SetAttr FILE="<filepath>" META="releasedate:<YYYYMMDD>"

Below is the altered version of the old script.

As well as changing the command it runs, I made it use selected_files instead of selected, so it doesn't try to do this to folders. Folders don't have a release date property, so it wouldn't make sense to try to handle them.

Option Explicit
Function OnClick(ByRef clickData)
	Dim strDateTime, strCommand, selItem, re, cmd

	Set re = new RegExp
	re.IgnoreCase = True
	re.Global = False
	' File name should be something like "20110729_anything"
	re.Pattern = "^(\d\d\d\d\d\d\d\d)_.*$"

	Set cmd = clickData.func.command
	cmd.ClearFiles

	For Each selItem in clickData.func.sourcetab.selected_files
		If (re.Test(selItem.Path.filepart)) Then
			' Set strDateTime to a string like "20110729"
			strDateTime = re.Replace(selItem.Path.filepart, "$1")
			' DOpus.Output "DT  = " & strDateTime
			strCommand = "SetAttr FILE=""" & selItem.RealPath & """ META=""releasedate:" & strDateTime & """"
			' DOpus.Output "CMD = " & strCommand
			cmd.RunCommand strCommand
		End If
	Next
End Function

Thank you. Wonderful. It worked on MP4 files.