Rename PATTERN="*" TO="*" @script vbscript Option Explicit ' Original script by MrC ' http://resource.dopus.com/viewtopic.php?f=3&t=19704&hilit=setattr+modify&start=20#p106752 ' ' Modified to work (extraneous \ added to file paths). ' Added folder date change. ' For information on the technique used in this button see: ' "Abusing" Rename Scripts to do other things with file info ' http://resource.dopus.com/viewtopic.php?t=8034 ' Change the path below if you haven't installed Opus to the default location: dim DOpusRTPath 'DOpusRTPath = "%ProgramFiles%\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 = "" ' 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, fIsFolder) 'DOpus.OutputString "Date A = " & strDateTime ElseIf (re0.Test(strFileName)) Then strDateTime = re0.Replace(strFileName, "$4$3$1") strDateTime = strDateTime & " " & GetFileModTime(strFilePath & strFileName, fIsFolder) '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, fIsFolder) '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, fIsFolder) 'DOpus.OutputString "Date 4 = " & strDateTime End If If (Not IsEmpty(strDateTime)) Then 'DOpus.OutputString "Set Date & Time = " & strDateTime strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=" & Q(strFilePath & strFileName) & " MODIFIED=" & Q(strDateTime) 'DOpus.OutputString "CMD = " & strCommand Shell.Run strCommand,0,true End If End Function Function GetFileModTime(filespec, isdir) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") If isdir Then Set f= fso.GetFolder(filespec) Else Set f = fso.GetFile(filespec) End If s = split(f.DateLastModified, " ", -1, 1) GetFileModTime = s(1) End Function Function Q(s) Q = """" & s & """" End Function