ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Finished Programs

DONE: Change (sub) folder(s) date based on newest/oldest file in the folder

<< < (21/32) > >>

4wd:
FolderNameXYZ 10-02-2014         with folder modified date 01-12-2013

then folder modified date to be updated to 10-02-2014-dcwul62 (February 11, 2014, 05:46 AM)
--- End quote ---

You could do it in DOpus using a Rename script but naturally you need to specify RegEx to get the info you want from the name ... also naturally, if the date format changes, you have to change the RegEx.


Luckily, someone has done it: Change modified date after filename

dcwul62:

Regretfully, sofar I have not found any tool (renamers or attribute/date time tools), regex or whatever
that changes the modified date of a  folder  based on a date in the foldername.

=

4wd:
You need to learn a little VBScript :)

DONE: Change (sub) folder(s) date based on newest/oldest file in the folder

For DOpus 11:


--- Code: Text ---@script vbscriptOption Explicit ' Original script by MrC' http://resource.dopus.com/viewtopic.php?f=3&t=19704&start=20#p106752'' Modified for DOpus 11 Dim file, strDateTime, attrcmd ' 10 digits, dash, 4 digits space dd-mm-yyyy.pdfDim reASet reA = new RegExpreA.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 DateDim re0Set re0 = new RegExpre0.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 separatorsDim re1Set re1 = new RegExpre1.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 separatorsDim re2Set re2 = new RegExpre2.Pattern = "^(?:.*?)[-\s]*(\d{2})([-\s]*)(\d{2})\2(\d{4})(?:.*)$"   ' Date / Time pattern: yyyy-mm-dd hh mm ssDim re3Set re3 = new RegExpre3.Pattern = "^(?:.*?)[-\s]*(\d{4}([-\s]*)\d{2}\2\d{2})[-\s]+(\d{2})([-\s]?)(\d{2})\4(\d{2})(?:.*?)$" ' Date pattern: yyyy-mm-ddDim re4Set re4 = new RegExpre4.Pattern = "^(?:.*?)[-\s]*(\d{4}([-\s]*)\d{2}\2\d{2})(?:.*)$" Dim reTimeSet reTime = new RegExpreTime.Pattern = "^(?:.*?)\s(\d{2}):(\d{2}):(\d{2})(?:.*)$" DOpus.OutputString "---- DateFromName ----"Function OnClick(ByRef ClickData)  For Each file In ClickData.func.sourcetab.selected'    If file.is_dir Then             ' --- Uncomment this and "End If" below if you only want it to act on folders      DOpus.OutputString Q(file.path & file.name) & "|" & file.modify_utc & "|" & file.modify      If (reA.Test(file.name)) Then        strDateTime = reA.Replace(file.name, "$3$2$1")           strDateTime = strDateTime & " " & reTime.Replace(file.modify, "$1:$2:$3")        DOpus.OutputString "Date A  = " & strDateTime      ElseIf (re0.Test(file.name)) Then        strDateTime = re0.Replace(file.name, "$4$3$1")           strDateTime = strDateTime & " " & reTime.Replace(file.modify, "$1:$2:$3")        DOpus.OutputString "Date 0  = " & strDateTime      ElseIf (re1.Test(file.name)) Then        strDateTime = re1.Replace(strFileName, "$4$3$1 $5:$7:$8")        DOpus.OutputString "Date 1  = " & strDateTime      ElseIf (re2.Test(file.name)) Then        strDateTime = re2.Replace(file.name, "$4$3$1")        strDateTime = strDateTime & " " & reTime.Replace(file.modify, "$1:$2:$3")        DOpus.OutputString "Date 2  = " & strDateTime      ElseIf (re3.Test(file.name)) Then        strDateTime = re3.Replace(file.name, "$1 $3:$5:$6")        DOpus.OutputString "Date 3  = " & strDateTime      ElseIf (re4.Test(file.name)) Then        strDateTime = re4.Replace(file.name, "$1")        strDateTime = strDateTime & " " & reTime.Replace(file.modify, "$1:$2:$3")        DOpus.OutputString "Date 4  = " & strDateTime      End If       If (Not IsEmpty(strDateTime)) Then        DOpus.OutputString "New Date & Time: " & strDateTime        attrcmd = "SetAttr FILE=" & Q(file.path & file.name) & " MODIFIED=" & Q(strDateTime)        DOpus.OutputString attrcmd        ClickData.func.command.RunCommand attrcmd      End If'    End If      ' --- Uncomment to match "If file.is_dir Then" statement above  NextEnd Function Function Q(s)  Q = """" & s & """"End Function

And the previous VBScript runs SetFolDateFM only on the newly created folders, not all of them.

dcwul62:

Sorry - I can't get it working.
Feel sad to say that....  :(

If the script is for a button, in Opus v10.x I need to add:
Rename PATTERN="*" TO="*"

as first line.
So:
Rename PATTERN="*" TO="*"
@script vbscript
Option Explicit
..etc.

Without that 1st line, I get an error.

In the Rename panel nothing happens.
=
DONE: Change (sub) folder(s) date based on newest/oldest file in the folder
=

=
DONE: Change (sub) folder(s) date based on newest/oldest file in the folder
=

Cud you guide me?
Opus v.10.5

=

4wd:
Sorry - I can't get it working.
Feel sad to say that....  :(-dcwul62 (February 12, 2014, 08:57 AM)
--- End quote ---

Believe or not, there is a reason I wrote For DOPUS 11  ;)
The methods and properties used in the script don't exist in DOpus 10.

If the script is for a button, in Opus v10.x I need to add:
--- End quote ---

It won't work in anything lower than DOpus 11 - I don't have DOpus 10 installed and like Innuendo, come the day DOpus 11 is up for sale some of my cash will be going their way.  Writing scripts is so much easier in DOpus 11 because a lot more information is easier to get at and use now.

For DOpus 10:


--- Code: Text ---Rename PATTERN="*" TO="*"@script vbscriptOption 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 DOpusRTPathDOpusRTPath = "%ProgramFiles%\GPSoftware\Directory Opus\dopusrt.exe" Dim ShellSet 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 = Q(DOpusRTPath) & " /cmd SetAttr FILE=" & Q(strFilePath & strFileName) & " MODIFIED=" & Q(strDateTime)    'DOpus.OutputString "CMD = " & strCommand    Shell.Run strCommand,0,true  End IfEnd 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
And it is not a Rename preset - see here.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version