# Change modified date after filename

**URL:** https://resource.dopus.com/t/change-modified-date-after-filename/15994
**Category:** Help & Support
**Created:** [July 14, 2013, 6:44am UTC](https://resource.dopus.com/t/change-modified-date-after-filename/15994 "2013-07-14T06:44:16Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![MrC](https://resource.dopus.com/letter_avatar_proxy/v4/letter/m/43a26b/32.png) [@MrC](https://resource.dopus.com/u/MrC)
#### Post date: [July 18, 2013, 7:23pm UTC](https://resource.dopus.com/t/change-modified-date-after-filename/15994/6 "2013-07-18T19:23:12Z")

</div>

I found the script:

[File name to modified date/time?](https://resource.dopus.com/t/file-name-to-modified-date-time/11522/1)

Replace the button script with the following:

```auto
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")
Dim re1, re2
Set re1 = new RegExp
Set re2 = new RegExp
Function Rename_GetNewName(strFileName, strFilePath, fIsFolder, strOldName, ByRef strNewName)
	Dim strYYYYMMDD
	Dim strCommand
	' Set strNewName to an empty string so that Opus does not rename the file.
	strNewName = ""
	re1.IgnoreCase = True
	re1.Global = False
	re2.IgnoreCase = True
	re2.Global = False
	' Test these date patterns: -dd-mm-yyyy or ddmmyyyy
	re1.Pattern = "^(?:.*?)(?:-(\d{2})-(\d{2})-(\d{4})|(\d{2})(\d{2})(\d{4}))(?:.*)$"
	' Test this date pattern: -yyyy-mm-dd
	re2.Pattern = "^(?:.*?)-(\d{4}-\d{2}-\d{2})(?:.*)$"
	
	If (re1.Test(strFileName)) Then
		' Set strYYYYMMDD to a string like "2011-07-29"
		strYYYYMMDD = re1.Replace(strFileName, "$3$2$1$6$5$4")
	ElseIf (re2.Test(strFileName)) Then
		' Set strYYYYMMDD to a string like "2011-07-29"
		strYYYYMMDD = re2.Replace(strFileName, "$1")
	End If
	If (Not IsEmpty(strYYYYMMDD)) Then
		'DOpus.OutputString "YYYYMMDD = " & strYYYYMMDD
		strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFilePath & "\" & strFileName & """ MODIFIED=""" & strYYYYMMDD & """"
		'DOpus.OutputString "CMD = " & strCommand
		Shell.Run strCommand,0,true
	End If
End Function
```

---

_[View the full topic](https://resource.dopus.com/t/change-modified-date-after-filename/15994)._
