Well, thank you very much, Sir! Do you ever stop working?? Whether you do or don't, one thing's for sure, I don't know how the hell I coped without DO all those years LOL.
Cheers, you're a star.
Well, thank you very much, Sir! Do you ever stop working?? Whether you do or don't, one thing's for sure, I don't know how the hell I coped without DO all those years LOL.
Cheers, you're a star.
So... I'm back for my bi-annual nuisance visit!
Is there a way to have the rename script take a filename (YYYY-MM-DD_HHMMSS.mp3) and adjust the 'modified date' to the [file name] + [mp3 duration] ?
The example in question would be file(s) which have been 'date-named' and converted to a new format (e.g. WMA > mp3) thus losing their original modified date and time, which of course differs from the created ones.
I know, it's insane..... That's me tho.
I would like to use this button with the inverse operation, i.e. first store the date_time into the file name, but I can't find the inverse function of SetAttr.
The SetAttr command is for changing dates and attributes.
The Rename command is what you need if you want to change the filename. You can use the enable file information fields checkbox in the rename dialog (or FILEINFO argument if you're making a button to automate things) which then gives you a drop-down to insert codes, including ones for the file's dates and times.
See Renaming with Metadata for more information.
Indeed, thanks!
With thanks to MrC, who has really done a great job in creating a script which may do most (if not all) what you need, you may wish to have a look at
thread: Change modified date after filename
specifically his last script, posted on 23 Aug 2013.
I admit, it is a bit of a tailor-made script and you need to test it first.
For example : your filename reads:
Filename 2011-07-29_082609.mp3
if you were to rename the filenames by removing the underscore (Filename 2011-07-29 082609.mp3), it will run just fine.
I have created a "Date from filename"-button to do the redates.
Dear Leo et al,
I have just tried your 2017 / Dopus 12 script and works fine with the filename format "YYYY-MM-DD_HH-MM-SS". I have even made a minor edit for changing the Creation Date attribute, instead of the Modified Date.
How this script can be modified for extracting the date from a format of "YYYYMMDD_" from either the filename OR from the folder-name? (two different scripts, on two buttons, are fine!)
Thank you!
Change these two lines to be like this:
...
re.Pattern = "^(\d\d\d\d\d\d\d\d)_.*$"
...
strDateTime = re.Replace(selItem.name_stem_m, "$1")
...
This looks at the parent folder name instead of the file name:
Option Explicit
Function OnClick(ByRef clickData)
Dim strDateTime, strCommand, selItem, re, cmd
Set re = new RegExp
re.IgnoreCase = True
re.Global = False
' Folder 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
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 & """ MODIFIED=""" & strDateTime & """"
' DOpus.Output "CMD = " & strCommand
cmd.RunCommand strCommand
End If
Next
End Function
(Change MODIFIED
to CREATED
as well if you want to set that timestamp instead.)
As expected, works smoothly! A last point, how the scripts may also set the TIME as 00:00:00?
Thank you.
Change "$1"
to "$1 00:00:00"
Thank you very much dear Leo!
I just ran into the same issue. Since this topic is like 10 years old, do we have now some new moments? as Opus command set has significantly raised in power since...
I need to set the modified date from the first part of the filenames like this:
My locale date format is "dd.MM.yyyy" - I'm not sure how it would interfere with all that business?
Thanks in advance.
The topic is old but the solution in the 4th post was "Updated for 2017 / Directory Opus 12" and is still current.
You'd need to adjust the regex search and replace strings. Probably something like these:
re.Pattern = "^(\d\d\d\d)\.(\d\d)\.(\d\d) - .*"
...
strDateTime = re.Replace(selItem.name_stem_m, "$1-$2-$3")
Try it on some test files first, of course.
Is it time to split the thread? Into one about renaming and a second one about attribute setting?
This could be a good idea. I kinda got lost over there.
Apart from 3 short posts in the middle, the whole thread is about setting timestamps from filenames, including the start of the thread and the new posts this week.
(There was a Rename command in the original, old solution, because that was a way to run scripts in the past, before there was more widespread scripting support. It wasn't really renaming anything though, and the newer solution doesn't need that method.)
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.
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.