Change modified date after filename

:thumbsup: :thumbsup:

what else to say...

thanks again.

From a private message from mrwul regarding another pattern to match:

Here's your new code which handles this additional case:

Rename PATTERN="*" TO="*"
@script vbscript
Option Explicit
' For information on the technique used in this button see:
' "Abusing" Rename Scripts to do other things with file info
' https://resource.dopus.com/t/abusing-rename-scripts-to-do-other-things-with-file-info/5969/1
' Change the path below if you haven't installed Opus to the default location:
dim DOpusRTPath
DOpusRTPath = "%ProgramFiles%\GPSoftware\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")

Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
   Dim strDateTime
   Dim strCommand
   ' Set strNewName to an empty string so that Opus does not rename the file.
   strNewName = ""

   ' Date / Scan Date pattern: dd mm yyyy ddmmyyyy, with possible space or dash separators in Date
   Dim re0
   Set re0 = new RegExp
   re0.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})[-\s]+(\d{8})(?:.*?)$"

   ' Date / Time pattern: dd mm yyyy hh mm ss, with possible space or dash separators
   Dim re1
   Set re1 = new RegExp
   re1.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})[-\s]+(\d{2})([-\s]?)(\d{2})\6(\d{2})(?:.*?)$"

   ' Date pattern: dd mm yyyy, with possible space or dash separators
   Dim re2
   Set re2 = new RegExp
   re2.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})(?:.*)$"
   
   ' Date / Time pattern: yyyy-mm-dd hh mm ss
   Dim re3
   Set re3 = new RegExp
   re3.Pattern = "^(?:.*?)[-\s]*(\d{4}([-\s]*)\d{2}\2\d{2})[-\s]+(\d{2})([-\s]?)(\d{2})\4(\d{2})(?:.*?)$"

   ' Date pattern: yyyy-mm-dd
   Dim re4
   Set re4 = new RegExp
   re4.Pattern = "^(?:.*?)[-\s]*(\d{4}([-\s]*)\d{2}\2\d{2})(?:.*)$"

   If (re0.Test(strFileName)) Then
      strDateTime = re0.Replace(strFileName, "$4$3$1")    
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date 0  = " & strDateTime
   ElseIf (re1.Test(strFileName)) Then
      strDateTime = re1.Replace(strFileName, "$4$3$1 $5:$7:$8")
      'DOpus.OutputString "Date 1  = " & strDateTime
   ElseIf (re2.Test(strFileName)) Then
      strDateTime = re2.Replace(strFileName, "$4$3$1")
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date 2  = " & strDateTime
   ElseIf (re3.Test(strFileName)) Then
      strDateTime = re3.Replace(strFileName, "$1 $3:$5:$6")
      'DOpus.OutputString "Date 3  = " & strDateTime
   ElseIf (re4.Test(strFileName)) Then
      strDateTime = re4.Replace(strFileName, "$1")
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date 4  = " & strDateTime
   End If
   
   If (Not IsEmpty(strDateTime)) Then
      'DOpus.OutputString "Set Date & Time  = " & strDateTime
      strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFilePath & "\" & strFileName & """ MODIFIED=""" & strDateTime & """"
      'DOpus.OutputString "CMD = " & strCommand
      Shell.Run strCommand,0,true
   End If
End Function

Function GetFileModTime(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   s = split(f.DateLastModified, " ", -1, 1) 
   GetFileModTime = s(1)
End Function

Thank you so much!

My new 'Redate from Filename'-button with this code... it's working fantastic now.

Again, thanks!! :thumbsup:

=

Hi MrC

I am very regularly using this DateFromFIlename button, am rrreally glad with it!

=

However, right now, I am facing a little issue here.
I have a set of filenames (about 60-70) that only contains digits.

They all are having a format exactly as follows

1234567890-1234 29-12-2008.pdf

i.e. 10 digits, dash, 4 digits space dd-mm-yyyy.pdf

I ran the Date From Filename-button and now the dates are really looking silly :smiley:
with years 7000 something.

Hate to ask, but eh... Is there a way you cud update your code?

(\d{2})-(\d{2})-(\d{4})

As always many thanks!

=

Here you go:

Rename PATTERN="*" TO="*"
@script vbscript
Option Explicit
' For information on the technique used in this button see:
' "Abusing" Rename Scripts to do other things with file info
' https://resource.dopus.com/t/abusing-rename-scripts-to-do-other-things-with-file-info/5969/1
' Change the path below if you haven't installed Opus to the default location:
dim DOpusRTPath
DOpusRTPath = "%ProgramFiles%\GPSoftware\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")

Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
   Dim strDateTime
   Dim strCommand
   ' Set strNewName to an empty string so that Opus does not rename the file.
   strNewName = ""

   ' 10 digits, dash, 4 digits space dd-mm-yyyy.pdf
   Dim reA
   Set reA = new RegExp
   reA.Pattern = "^\d{10}-\d{4} (\d{2})-(\d{2})-(\d{4})(?:.*?)$"

   ' Date / Scan Date pattern: dd mm yyyy ddmmyyyy, with possible space or dash separators in Date
   Dim re0
   Set re0 = new RegExp
   re0.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})[-\s]+(\d{8})(?:.*?)$"

   ' Date / Time pattern: dd mm yyyy hh mm ss, with possible space or dash separators
   Dim re1
   Set re1 = new RegExp
   re1.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})[-\s]+(\d{2})([-\s]?)(\d{2})\6(\d{2})(?:.*?)$"

   ' Date pattern: dd mm yyyy, with possible space or dash separators
   Dim re2
   Set re2 = new RegExp
   re2.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})(?:.*)$"
   
   ' Date / Time pattern: yyyy-mm-dd hh mm ss
   Dim re3
   Set re3 = new RegExp
   re3.Pattern = "^(?:.*?)[-\s]*(\d{4}([-\s]*)\d{2}\2\d{2})[-\s]+(\d{2})([-\s]?)(\d{2})\4(\d{2})(?:.*?)$"

   ' Date pattern: yyyy-mm-dd
   Dim re4
   Set re4 = new RegExp
   re4.Pattern = "^(?:.*?)[-\s]*(\d{4}([-\s]*)\d{2}\2\d{2})(?:.*)$"

   If (reA.Test(strFileName)) Then
      strDateTime = reA.Replace(strFileName, "$3$2$1")    
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date A  = " & strDateTime
   ElseIf (re0.Test(strFileName)) Then
      strDateTime = re0.Replace(strFileName, "$4$3$1")    
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date 0  = " & strDateTime
   ElseIf (re1.Test(strFileName)) Then
      strDateTime = re1.Replace(strFileName, "$4$3$1 $5:$7:$8")
      'DOpus.OutputString "Date 1  = " & strDateTime
   ElseIf (re2.Test(strFileName)) Then
      strDateTime = re2.Replace(strFileName, "$4$3$1")
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date 2  = " & strDateTime
   ElseIf (re3.Test(strFileName)) Then
      strDateTime = re3.Replace(strFileName, "$1 $3:$5:$6")
      'DOpus.OutputString "Date 3  = " & strDateTime
   ElseIf (re4.Test(strFileName)) Then
      strDateTime = re4.Replace(strFileName, "$1")
      strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      'DOpus.OutputString "Date 4  = " & strDateTime
   End If
   
   If (Not IsEmpty(strDateTime)) Then
      'DOpus.OutputString "Set Date & Time  = " & strDateTime
      strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFilePath & "\" & strFileName & """ MODIFIED=""" & strDateTime & """"
      'DOpus.OutputString "CMD = " & strCommand
      Shell.Run strCommand,0,true
   End If
End Function

Function GetFileModTime(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   s = split(f.DateLastModified, " ", -1, 1) 
   GetFileModTime = s(1)
End Function

Incredible !! :thumbsup:

This saved me a lot of (boring) time on setting new modified/creating date, file-by-file.

Thank you soo much!

What else to say ...

=

@mrc - sofar this button helped a lot and I have been using it very frequently.
I am not sure if the below can be solved easily. If not, forget it, I'll have to handle this manually.
Up front, it is my mistake... I did not pay attention to it. Period.
Nothing wrong with the tool.

That said, I have - in a kind of 'batch-action'- changed modified dates to, let's say, 'unlikely' dates.
Example: file-xyz-1309428842.pdf got dated 13-09-4288
The number in the file in fact has no relation to a date, but is some accountnumber.

a) the number is not a dateformat (like: ddmmyyyy, ddmmyy, dd-mm-yyyy, dd-mm-yy)
b) the year is beyond the scrope : a reasonable scope would be 1900-2050

Again, it definitely is my fault, I did not pay attention to it.

Is there anything that could be done to avoid this in future?

Thanks

Further t the above, I got an error when redating a file like this:
(example)

AccountOverview 2002-1309114435 15-01-2002.pdf
(An error occurred modifying ... bla bla
The parameter is wrong (87)

Maybe the following could be added to the button script?

=

\d{2}-\d{2}-\d{4}\.(\w{2,4})

Thanks again.

If you are willing to install the free ActivePerl, I'll rewrite the script in perl and give you the bounds checking you want. Adding additional tests or changing the existing script to test the captured values is too painful in vbscript.

Thanks for yr quick comments.
I''ll consider it. Timebeing let it rest. I''ll try to solve this manually timebeing.

Have been hesitating for quite a while to ask...
I really use this script very often. One thing is still missing and I wonder if that could be added

Have a lot of files that are named as follows

Filename This and That_20121002_2027.ext

(note the underscores)

the regex find/replace would read something like:
find: (.+)(20[01]\d)(0[1-9]|1[0-2])(\d{2})(\d{2})(\d{2}).(\w{2,4})
repl: $1_$4$3$2_$5$6$5.$7

note: for seconds I have used the hours ($5), not important.

however, I don't know how to fit this in the existing script.

However,if the time stamp updating is too complicated, then leave it,
the current script updates the date already.
It would be nice to have the timestamp updated as well, but as said:

if too complex
.... then forget it
endif

:wink:

Thanks.

Rename PATTERN="*" TO="*"
@script vbscript
Option Explicit
' For information on the technique used in this button see:
' "Abusing" Rename Scripts to do other things with file info
' https://resource.dopus.com/t/abusing-rename-scripts-to-do-other-things-with-file-info/5969/1
' Change the path below if you haven't installed Opus to the default location:
dim DOpusRTPath
'DOpusRTPath = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"
DOpusRTPath = "F:\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")

Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
   Dim strDateTime
   Dim strCommand
   ' Set strNewName to an empty string so that Opus does not rename the file.
   strNewName = ""
   Dim debstr
   Dim gettimestamp
   gettimestamp = 0

   ' 10 digits, dash, 4 digits space dd-mm-yyyy.pdf
   ' e.g.  1234567890-1234 29-12-2008.pdf
   Dim reA
   Set reA = new RegExp
   reA.Pattern = "^\d{10}-\d{4} (\d{2})-(\d{2})-(\d{4})(?:.*?)$"

   ' Date / Scan Date pattern: dd mm yyyy ddmmyyyy, with possible space or dash separators in Date
   ' e.g. filename-01-12-2013 10-11-12.pdf
   Dim re0
   Set re0 = new RegExp
   re0.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(20[01]\d)[-\s]+(\d{8})(?:.*?)$"

   ' Date / Time pattern: dd mm yyyy hh mm ss, with possible space or dash separators
   'e.g. Whatever Other Filename-25-10-2013 064428.ext
   Dim re1
   Set re1 = new RegExp
   re1.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(0[1-9]|1[0-2])\2(20[01]\d)[-\s]+(\d{2})([-\s]?)(\d{2})\6(\d{2})(?:.*?)$"

   ' Date pattern: dd mm yyyy, with possible space or dash separators
   ' e.g. filename-01122013.ext or filename-01-12-2013 121212.ext
   Dim re2
   Set re2 = new RegExp
   re2.Pattern = "^.*?[-\s]*(\d{2})([-\s]*)(0[1-9]|1[0-2])\2(20[01]\d).*$"
   
   ' Date / Time pattern: yyyy-mm-dd hh mm ss
   Dim re3
   Set re3 = new RegExp
   re3.Pattern = "^.*?[-\s]*(20[01]\d([-\s]*)(0[1-9]|1[0-2])\2\d{2})[-\s]+(\d{2})([-\s]?)(\d{2})\4(\d{2}).*?$"

   ' Date pattern: yyyy-mm-dd
   ' e.g. Lorem Ipsum - 11 - 2013-06-03.jpg or Lorem Ipsum - 11 - 2013-06-03_164921.jpg
   Dim re4
   Set re4 = new RegExp
   re4.Pattern = "^.*?[-\s]*(20[01]\d([-\s]*)(?:0[1-9]|1[0-2])\2\d{2}).*$"

   ' Date pattern: 20yymmdd.ext or 20yy-mm-dd.ext
   ' e.g. filename-20131201.ext or Filename-2013-12-01.ext
   Dim re5
   Set re5 = new RegExp
   re5.Pattern = "^.*?[-\s]*(20[01]\d([-\s]*)(?:0[1-9]|1[0-2])\2\d{2})\.(\w{2,4})"

   ' Date pattern: 19yy-mm-dd.ext or 19yymmdd.ext
   ' e.g. filename-19970301.ext or filename-1950-05-03.ext
   Dim re6
   Set re6 = new RegExp
   re6.Pattern = "^.*?[-\s]*(19[2-9]\d)([-\s]*)(0[1-9]|1[0-2])([-\s]*)(\d{2})\.(\w{2,4})"

   ' Date pattern: dd-mm-19yy.ext or ddmm19yy.ext
   ' e.g. File-03-05111965.html or File-11-03-12-1997.html
   Dim re7
   Set re7 = new RegExp
   re7.Pattern = "^.*?[-\s]*(\d{2})([-\s]*)(0[1-9]|1[0-2])([-\s]*)(19[2-9]\d)\.(\w{2,4})"

    'Date pattern: filename-dd-ddmm19yy hhmmss.ext
    'e.g. Lorem Ipsum-11-19041993 163632.jpg
   Dim re8
   Set re8 = new RegExp
   re8.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(0[1-9]|1[0-2])\2(19[2-9]\d)[-\s]+(\d{2})([-\s]?)(\d{2})\6(\d{2})(?:.*?)$"





   If (reA.Test(strFileName)) Then
      strDateTime = reA.Replace(strFileName, "$3$2$1")
      gettimestamp = 1
      debstr = "(A): " & strDateTime
   ElseIf (re0.Test(strFileName)) Then
      strDateTime = re0.Replace(strFileName, "$4$3$1")
      gettimestamp = 1
      debstr =  "(0): " & strDateTime
   ElseIf (re1.Test(strFileName)) Then
      strDateTime = re1.Replace(strFileName, "$4$3$1 $5:$7:$8")
      debstr = "(1): " & strDateTime
   ElseIf (re2.Test(strFileName)) Then
      strDateTime = re2.Replace(strFileName, "$4$3$1")
      gettimestamp = 1
      debstr =  "(2): " & strDateTime
   ElseIf (re3.Test(strFileName)) Then
      strDateTime = re3.Replace(strFileName, "$1 $3:$5:$6")
      debstr =  "(3): " & strDateTime
   ElseIf (re4.Test(strFileName)) Then
      strDateTime = re4.Replace(strFileName, "$1")
      gettimestamp = 1
      debstr =  "(4): " & strDateTime
   ElseIf (re5.Test(strFileName)) Then
      strDateTime = re5.Replace(strFileName, "$1")
      gettimestamp = 1
      debstr =  "(5): " & strDateTime

   ElseIf (re6.Test(strFileName)) Then
      strDateTime = re6.Replace(strFileName, "$1$3$5")
      gettimestamp = 1
      debstr =  "(6): " & strDateTime

   ElseIf (re7.Test(strFileName)) Then
      strDateTime = re7.Replace(strFileName, "$5$3$1")
      gettimestamp = 1
      debstr =  "(7): " & strDateTime

   ElseIf (re8.Test(strFileName)) Then
      strDateTime = re8.Replace(strFileName, "$4$3$1 $5:$7:$8")
      gettimestamp = 1
      debstr =  "(8): " & strDateTime




   End If
   
   If (Not IsEmpty(strDateTime)) Then
      If (gettimestamp) Then
            strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      End If
      'DOpus.OutputString "Set Date & Time " & debstr
      strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFilePath & "\" & strFileName & """ MODIFIED=""" & strDateTime & """"
      'DOpus.OutputString "CMD = " & strCommand
      Shell.Run strCommand,0,true
   End If
End Function

Function GetFileModTime(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   s = split(f.DateLastModified, " ", -1, 1)
   GetFileModTime = s(1)
End Function

HI opw62,

I had already re-written the script to Perl for you last Sept, as it is far simpler to modify to add new cases. You can see how incredibly clumsy this is to accomplish in vbscript, and as I mentioned a couple of posts above, I'd prefer not to spend any more adding yet another case.

I already added the Date Guessing feature to Dynamic Renamer, so that code replacing the static patterns in the script I had written for you solves the problem more generally for all but the most egregious cases, and does proper date validation. Additional static cases would supplement those.

That said, your pattern is easy, but you'll have to place it in the correct location in the If/ElseIf sequence to match. I haven't examined which other case this will conflict with:

   ' Date pattern: 20yymmdd.ext or 20yy-mm-dd.ext
   ' e.g. stuff_20131201_morestuff.ext
   Dim re99
   Set re99 = new RegExp
   re99.Pattern = "^.*?_(20[01]\d)(0[1-9]|1[0-2])(\d{2})_.*$"

...

    ElseIf (re99.Test(strFileName)) Then
      strDateTime = re99.Replace(strFileName, "$1-$2-$3")
      gettimestamp = 1
      debstr =  "(99): " & strDateTime

You have many unnecessary pattern captures in your recent additions and your post above, and I think you're not understanding the essential captures. All you need to capture is the 4 digit year, the 2 digit month, and the 2 digit day (for date-only patterns in your filenames). Then, you output these in the sequence YYYY-MM-DD in the Replace function (notice the $1-$2-$3 in the replace).

Use (?:stuff) when you don't want to capture, but want to cloister (aka group).

Hi MrC
Yes, I know you suggested to install ActivePerl.
And I did have a look at the ActiveState website.
And I did consider to install it.

Why I didn't..?

Well, it is because I wasn't sure there would be any further changes in the near future.
The 'Date from file name'-script actually worked fine for a about a year now.

Also I assumed that if the code is in ActivePerl, the I always have to install ActivePerl on my system just to make use of the
Date from Filename 'feature', i.e. if it isn't installed, then it won't work.
As I am trying to keep my pc as clean as possible I hesitate to install additional stuff just to make 1 feature work, a feature
that already works fine, without ActivePerl installed.
I hope you understand my position.

That said, I'll have to accept that you will stop support in vbscript. I won't be asking anymore.

To persuade you to help me one more time, I added the regex code.

Will try it out soon.

Many thanks indeed for your help!

=

MrC - getting back on this old thread.

First of all - I did install ActivePerl a little while ago. You may remember me advising that 5.16 wasn't available.
But then I was facing this "Now what?' situation, i.e. "what am I supposed to do now?"
Whilst fearing that I would end up with all kinds of complicated things, looking like a fool having to ask a dozen things, well, I uninstalled it.

Regretfully though I have to get back to you. The script workings fine on my current system.
I downloaded a trial version of Opus on my other pc (32bit) and restored the backup of my current Opus to that.
It seems all buttons are there, in the trial version.

When running the script it got me an error: 0x80070002
(Searched on Internet, seems this is more or less related when installing software?)

I tried this script on my current pc with the same filename.
The date changed correctly, the time not, that has something to do with the missing seconds in the time.
But that's okay.

All that said, any idea as to why on 32b it doesn't run and on x64 it does?

=

If you want me to install ActivePerl I will gladly do so, but then pls I need your advice on what next steps I should take.

Thanks

It looks like part of the script is missing there, since it ends on line 127 while still inside an If ... ElseIf ... ElseIf ... structure. There's no End If on the end, and presumably other things also missing for some reason.

If you look at the script on both machines, is it the same?

I copied only the relevant part. It goes on.
Script runs fine on my current pc but stops with an error on my other pc with the trial version of Opus and restored .ocb.
As far as I can see both scripts are identical, a text compare shows no difference.

Tried using the latest iteration of this script, and don't have much luck, I get the following error in the script log, any ideas?

 2019-11-15 13:31  Error at line 1, position 20
 2019-11-15 13:31  Rename PATTERN="*" TO="*"
 2019-11-15 13:31                     ^
 2019-11-15 13:31  Expected end of statement (0x800a0401)
 2019-11-15 13:31  Parse error - script aborted

Set the Function drop-down to Standard Function, not Script Function.

(The code above starting with a Rename... line runs the Rename command and passes a script to it. The newer script buttons are something different, where the whole thing is a script.)

This is a script that I am regularly using. However, over time it has changed a bit.

Below is the one that I am currently using and is working fine. The code is far, far from sophisticated.
No doubt experts here can create a much better one, but for me, I am satisfied: it works.
If you intend to use it, change the path to dopusrt.exe

Rename PATTERN="*" TO="*"
@nodeselect
@script vbscript
Option Explicit
' IMPORTANT
' Change the path below if you haven't installed Opus to the default location:
dim DOpusRTPath
'DOpusRTPath = "C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe"
DOpusRTPath = "D:\Directory Opus\dopusrt.exe"
Dim Shell
Set Shell = CreateObject("WScript.Shell")

Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
   Dim strDateTime
   Dim strCommand
   ' Set strNewName to an empty string so that Opus does not rename the file.
   strNewName = ""
   Dim debstr
   Dim gettimestamp
   gettimestamp = 0

   ' ddmmyyyy hhmmss  dd-mm-yyyy  hh-mm-ss   dd mm yyyy  hh mm ss
   ' Date AND Time pattern: dd mm yyyy hh mm ss, with possible space or dash separators
   ' Filename-25-10-2013 064428.ext
   ' Filename-25102013 06-44-28.ext
   ' Filename-25-10-2013 06-44-28.ext
   ' Filename-25.10.2013 064423.ext
     Dim re0
     Set re0 = new RegExp
     re0.Pattern = "^(?:.*?)[-_\s]*(0[1-9]|[12][0-9]|3[01])[\s-_\.]?(0[1-9]|1[0-2])[\s-_\.]?(17[0-9][0-9]|18[0-9][0-9]|19[0-9][0-9]|20[0-2][0-9])[-\s_]?([0-1]\d|[2][0-3])[\s\-\_]?([0-5]\d)[\s\-\_]?([0-5]\d)\.(?:.*?)$"
 
   'yyyymmdd hhmmss  yyyy-mm-dd  hh-mm-ss   (with or without dashes)
   ' Date AND Time pattern: yyyy-mm-dd hh mm ss
   ' Filename-20131231 123456.ext 
   ' Filename-1999-11-01 12-34-56.ext 
   ' Filename-1999.11.01 123456.ext
   ' Filename-1999_11_01 12_34_56.ext
    Dim re1
    Set re1 = new RegExp
    re1.Pattern = "^(?:.*?)[-_\s]*(17[0-9][0-9]|18[0-9][0-9]|19[0-9][0-9]|20[0-2][0-9])[\s\-\_\.]?(0[1-9]|1[0-2])[\s\-\_\.]?(0[1-9]|[12][0-9]|3[01])[-\s_]?([0-1]\d|[2][0-3])[\s\-\_]?([0-5]\d)[\s\-\_]?([0-5]\d)\.(?:.*?)$"
 
   ' ddmmyyyy dd-mm-yyyy  Date ONLY (no time)
   ' Date / Scan Date ONLY (no time added): dd mm yyyy ddmmyyyy with possible space or dash separators in Date
   ' filename-01122013.pdf 
   ' filename-01-12-2013.pdf
   ' Filename-01.12.2013.ext
     Dim re2
     Set re2 = new RegExp
     re2.Pattern = "^(?:.*?)[-_\s]*(0[1-9]|[12][0-9]|3[01])[\s\-\_\.]?(0[1-9]|1[0-2])[\s\-\_\.]?(17[0-9][0-9]|18[0-9][0-9]|19[0-9][0-9]|20[0-2][0-9])\.(?:.*?)$"

   ' yyyy-mm-dd  yyyymmdd  date ONLY  without time
   ' Date pattern: yyyy mm dd yyyy-mm-dd yyyymmdd 
   ' Filename-20131231.ext 
   ' filename-1899-11-30.ext
   ' filename-1899.11.30.ext
     Dim re3
     Set re3 = new RegExp
     re3.Pattern = "^(?:.*?)[-_\s]*(17[0-9][0-9]|18[0-9][0-9]|19[0-9][0-9]|20[0-2][0-9])[\s\-\_\.]?(0[1-9]|1[0-2])[\s\-\_\.]?(0[1-9]|[12][0-9]|3[01])\.(?:.*?)$"

   If (re0.Test(strFileName)) Then
      strDateTime = re0.Replace(strFileName, "$3$2$1 $4:$5:$6")
      gettimestamp = 1
      debstr = "(0): " & strDateTime
   ElseIf (re1.Test(strFileName)) Then
      strDateTime = re1.Replace(strFileName, "$1$2$3 $4:$5:$6")
      gettimestamp = 1
      debstr =  "(1): " & strDateTime
   ElseIf (re2.Test(strFileName)) Then
      strDateTime = re2.Replace(strFileName, "$3$2$1")
      gettimestamp = 1
      debstr =  "(2): " & strDateTime
   ElseIf (re3.Test(strFileName)) Then
      strDateTime = re3.Replace(strFileName, "$1$2$3")
      gettimestamp = 1
      debstr =  "(3): " & strDateTime

   End If
   
  If (Not IsEmpty(strDateTime)) Then
      If (gettimestamp) Then
            strDateTime = strDateTime & " " & GetFileModTime(strFilePath & "\" & strFileName)
      End If
      DOpus.OutputString "Set Date & Time " & debstr
      strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFilePath & "\" & strFileName & """ MODIFIED=""" & strDateTime & """"
      DOpus.OutputString "CMD = " & strCommand
      Shell.Run strCommand,0,true
   End If
End Function

Function GetFileModTime(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   s = split(f.DateLastModified, " ", -1, 1)
   GetFileModTime = s(1)
End Function

I have a button in the toolbar that runs this script.

See below. Left all files with timestamp today, 12:00:00 right, date and if applicable time is adjusted.

1 Like