# Script adds extra backslash to path

**URL:** https://resource.dopus.com/t/script-adds-extra-backslash-to-path/33822
**Category:** Help & Support
**Created:** [October 25, 2019, 2:15pm UTC](https://resource.dopus.com/t/script-adds-extra-backslash-to-path/33822 "2019-10-25T14:15:16Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![opw62](https://resource.dopus.com/letter_avatar_proxy/v4/letter/o/5e9695/32.png) [@opw62](https://resource.dopus.com/u/opw62)
#### Post date: [October 28, 2019, 9:21am UTC](https://resource.dopus.com/t/script-adds-extra-backslash-to-path/33822/3 "2019-10-28T09:21:42Z")

</div>

Sorry for the delay. One way or the other, it looks I haven't received a notification, neither in the 'junk' box.  
Earlier posts can be found in thread "Change modified date after filename"

> [@Change modified date after filename](https://resource.dopus.com/t/change-modified-date-after-filename/15994/9):
>
> Regret, nothing happens. Anyway, forget it, many thanks for the effort! I have found a renamer that can do this job.

For experts this script probably looks crap, but it works fine for me.

For good order's sake below the script

```auto
Rename PATTERN="*" TO="*"
@nodeselect
@script vbscript
Option Explicit
' 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

   ' format: file name+ddmmyyyy hhmmss dd-mm-yyyy hh-mm-ss dd mm yyyy hh mm ss
     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)\.(?:.*?)$"

   ' format: file name+yyyymmdd hhmmss yyyy-mm-dd hh-mm-ss (with or without dashes)
    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)\.(?:.*?)$"

   ' format: file name+ddmmyyyy dd-mm-yyyy Date ONLY (no time)
     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])\.(?:.*?)$"

   ' format: file name+yyyy-mm-dd yyyymmdd date ONLY without time
     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

```

---

_[View the full topic](https://resource.dopus.com/t/script-adds-extra-backslash-to-path/33822)._
