Use Opus to Touch?

Leo's neat solution to the question raised in How to rename: same name different extension prompts me to ask if there is a way of using the "abusing rename" technique to apply the first selected file's modified timestamp to the second and subsequent selected file(s)?


Regards, AB

Here's the script.

Be careful since doing anything that causes the Rename window's preview list to refresh will cause the script to be run, setting the dates on all the files. So make sure you have the file you want at the top of the list before you open the Rename window.

[code]@script vbscript
Option Explicit
'
' For information on the technique used in this button see:
' "Abusing" Rename Scripts to do other things with file info
' [OBSOLETE] "Abusing" Rename Scripts to do other things with file info
'
' Change the path below if you haven't installed Opus to the default location:
dim DOpusRTPath
DOpusRTPath = "%ProgramFiles%\GPSoftware\Directory Opus\dopusrt.exe"
'
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim shell
Set Shell = CreateObject("WScript.Shell")

Dim strDateFirst

Function Rename_GetNewName ( strFileName, strFilePath, _
fIsFolder, strOldName, ByRef strNewName )

Dim dyear
Dim dmonth
Dim dday
Dim dhour
Dim dmin
Dim dsec

Dim fob
Dim strCommand

if fIsFolder then
Set fob = fso.GetFolder(strFilePath & "" & strFileName)
else
Set fob = fso.GetFile(strFilePath & "" & strFileName)
end if

if IsEmpty(strDateFirst) then

' Get date into a string like "2011-07-29 08:26:09"

dyear = CStr( Year( fob.DateLastModified ) )
dmonth = CStr( Month( fob.DateLastModified ) )
dday = CStr( Day( fob.DateLastModified ) )
dhour = CStr( Hour( fob.DateLastModified ) )
dmin = CStr( Minute( fob.DateLastModified ) )
dsec = CStr( Second( fob.DateLastModified ) )

strDateFirst = String(4-Len(dyear),"0") & dyear & "-" & String(2-Len(dmonth),"0") & dmonth & "-" & String(2-Len(dday),"0") & dday & " " & String(2-Len(dhour),"0") & dhour & ":" & String(2-Len(dmin),"0") & dmin & ":" & String(2-Len(dsec),"0") & dsec

else

strCommand = """" & DOpusRTPath & """ /cmd SetAttr FILE=""" & strFilePath & "" & strFileName & """ MODIFIED=""" & strDateFirst & """"

' DOpus.OutputString "CMD = " &strCommand

Shell.Run strCommand,0,true

end if

End Function[/code]