DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Last post Author Topic: DONE: Change (sub) folder(s) date based on newest/oldest file in the folder  (Read 187,587 times)

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
v0.3.1.2 - here
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Many, many thanks for SetFolDate v0.3.1.2 !

Fantastic!!

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
I am not sure - I am doing something wrong, definitely.
Cud you assist?

=
[attachthumb=#]
=

thanks a lot!

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Think I goofed there somewhere, I'll have a look at it.

Try the Explorer version in the meantime, seemed to work here.
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Yes, Explorer works fine indeed. ;)

As for Opus below for your info only.

=
SetFolDate-ToolbarButton-05022014 071225.png
=
SetFolDate-OUC-05022014 072036.png
=

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Hello again,
The below steps I am doing -very..- often.

In Directory Opus I have a number of items in the context menu (right window pane), that saves files to folders named of the filename.

e.g. I have files like.:
this is file1.txt
this is file2-01-01012014.txt
this is file3-01012014 12:34:56.txt

in the context menu of Opus I have a few commands that will save the files to new folders like:
folder this is my file1
folder this is my file2
folder this is my file3

2nd step is that I use setfoldate to change the dates of the newly created folders to set to newest filedate/

A bit this way

=
[attachthumb=#]
=

To move files to a folder I use various regex

e.g.
Create Filenamed Folder to MOVE to... (Date+Time)
Rename REGEXP PATTERN "(.+)(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})(-|\s)(\d{6})\.(.+)" TO \1\\\0

Sofar, everything okay.

I doNOT know if the below is possible(!)...

I would like to have the rename syntax (see above) to also include a way that setfoldate is executed default newest file recursive
so I donot need to do the 2nd step.
i.e. when I do a move to folder named after filename, then the folderdate is automatically adjusted.

Is this possible?

=




4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
Say you're saying that after all the, literally, minutes I spent slaving over its interface, you don't want to see it?
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
No, I did not say that...  don't get me wrong.
The interface is fine.

What I did ask is if it possible for specific tasks to run it 'silently' (without interface) in combination with the regex.
For all other tasks and users the interface should definitely remain in place.

If not, forget it, I will use the interface, just like I do now.

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: February 07, 2014, 10:02 AM by 4wd »

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
v0.3.1.3 - Added: Can run in no GUI mode using last saved options.

Here's an example UserCommand for DOpus:

Code: (xml)
<?xml version="1.0" encoding="UTF-8"?>
<usercommand backcol="none" hide_from_menu="no" textcol="none">
	<label>Adjust_Timestamp_NG</label>
	<user_label>Adjust_Timestamp_NG</user_label>
	<icon1>#usercommand</icon1>
	<function type="normal">
		<instruction>@dirsonly</instruction>
		<instruction>Go {ss}</instruction>
		<instruction>&quot;C:\SetFolDate2\SetFolDateFM.exe&quot; /r {ss} {allfile}</instruction>
	</function>
</usercommand>

@dcwul62 - in case it wasn't obvious, my remark about the GUI was the usual dry Aussie humour coming out  ;)

Albeit with a rather obvious grammatical screw-up  :-\
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: February 07, 2014, 10:05 AM by 4wd »

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
No problem  of course :)

Thanks for the work.
Solution is indeed very close. I need to select the folder and click on the button.

Tried to do the same without a toolbar button, but adding: "F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}
to the existing move to folder context menu.

=
[attach=#]
[attachthumb=#]
=

But that did not work out properly, regretfully so.

The newly created folder is nog selected, maybe that cannot be changed... and is normal behaviour.
When I select the folder, SetFolDate window, of course, disappears and should be brought up again from the taskbar.

The 'select folder' + 'adjust timestamp' should be skipped and should be done automatically.

Again.. maybe I asking something that is impossible. Really don't know.
The button works fine though.

THanks
=





4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
If, as shown in your image, you only have the one folder left after the rename then you could try adding:

Select ALLDIRS

before the SetFolDate command to select the folder, (well, all folders really).

Ideally, you'd set a variable to the folder you want to create and then use it as an argument to both the Rename and SetFolDate commands.
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: February 14, 2014, 06:10 AM by 4wd »

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Hello again,
I am not sure how to set a variable, but have spent quite some time on searching on Opus support site.
Up front: I have _no_ knowledge of the DOpus programming stuff!  I always try this, try that, try so-and-so, which is costing a lot of time.
Then again... frankly speaking, if, for me, it would not sense spending much time on trying to familiarize myself with DOpus programming:
except for the few tweaks here and there, I use it pretty much in default settings.

Anyway, somewhere in some forum thread I found  ' /p {sourcepath}  '
http://resource.dopus.com/viewtopic.php?p=43750

and added that to the setfoldatefm.exe line, so it now reads:

//
Rename REGEXP PATTERN "(.+)(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})(-|\s)(\d{6})\.(.+)" TO \1\\\0
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile} /p {sourcepath}
//


=
[attach=#]
=
[attachurl=#]
=

This way I now only need to click on the [Exec All]  button.
Can this be avoided?

p.s. Donot know if the video will be uploaded alright, else see http://s528.photobucket.com/user/phwul/media/SetFolDate/SetFolDateWithpsourcepath-08022014064538_zpsc53a37d9.mp4.html
=
« Last Edit: February 08, 2014, 08:50 AM by dcwul62 »

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile} /p {sourcepath}

Not going to work, the arguments /p {sourcepath} are what are passed to the locate32 program in the thread you mention.

SetFolDateFM.exe only has one option: /r

Try what I said, put Select ALLDIRS between Rename and SetFolDateFM:

Rename REGEXP PATTERN "(.+)(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})(-|\s)(\d{6})\.(.+)" TO \1\\\0
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: February 08, 2014, 12:09 PM by 4wd »

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Sel alldirs got me an error, unrecognized command or something.
the /p source thing, well, i just got that from that forumpost as apparently it could be used as a parameter or so.
there is a difference though between using it and nót using it.

below without /p {sourcepath}

http://s528.photobucket.com/user/phwul/media/SetFolDate/SetFolDatewithoutparameter-08-02-201409-58-23_zps647ba86d.mp4.html

One way or the other it has some effect ...  :)

=

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
One way or the other it has some effect ...  :)

Yes, but it's not going to do anything because this is what you're sending:

SetFolDateFM.exe /r sourcepath /p sourcepath

/r will be removed if it's there, therefore your final command line will be:

SetFolDateFM.exe sourcepath /p sourcepath

This is going to result in nothing happening since the folder /p doesn't exist, and sourcepath doesn't exist as a sub-directory of itself.

The reason the GUI appears is simple: there's at least 2 arguments in the command line (it doesn't matter what they are)

Also, my bad, the DOpus command is actually Select ALLDIRS but it still won't work because DOpus is executing the following line before the Select one can complete.
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Bad luck then  :(
What I want is not possible.

Anyway, many many thanks for your support sofar!

=

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336

Héé ... 99% okay!  :Thmbsup:  :Thmbsup:

=
[attachmini=#]

http://s528.photobucket.com/user/phwul/media/SetFolDate/SetFolDate-Update-08-02-201417-14-30_zps37042f3e.mp4.html
=

When there is 1 folder, it is okay, only when there are more folders, then I need to click on [Exec All]
But this is already a big help!

THANKS!

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
I can probably tweak it to automatically do Exec All rather than Exec which will take care of it.

It'd still be better to use a variable derived from the filename in the Rename/SetFolDate commands - something that's likely to be rather easy under DOpus 11.

Otherwise a VBScript, (@script vbscript), would be possible - I might look at that.

EDIT: Tweaked, try 0.3.1.4
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: February 09, 2014, 02:54 AM by 4wd »

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
WONDERFUL !!

Many many thanks 4wd !  :Thmbsup: :Thmbsup:

This is really great and for a timesaver...

again
thanks!

=
http://s528.photobucket.com/user/phwul/media/SetFolDate/SetFolDate-Update-Wonderful-09022014100700_zpsa7d7fcf1.mp4.html
=

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Oh, by the way ... it is perfect for me now (Opus)

where needed I added:

---
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}
---

Without using this, i.e. whilst using SetFolDate in the 'normal' (conventional, non context menu way), it works fine as well.


Have not tested it with Total Commander (donot have that) and also I have not tested it with explorer.
Assume it will work fine with those as well.

=

best regards
=

4wd

  • Pedantic Old Bastard
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,652
    • Coding Snacks
See later post.

Here's an exercise in DOpus scripting, (only tested on DOpus 11 - actually it only works on DOpus 11):

Code: (generic)
@script vbscript
Option Explicit

Dim regex, file, folder, rencmd, sfdcmd, WshShell

Function OnClick(ByRef ClickData)
  sfdcmd = "%programfiles%\GPSoftware\Directory Opus\SetFolDateFM.exe" ' Full path to SetFolDateFM.exe command

  Set WshShell = CreateObject("WScript.Shell")

  DOpus.OutputString "--- SetFolDate ---"
  Set regex = New RegExp
  With regex
    .Pattern    = "^([^\.-]+).*" ' Change the RegExp to what you want
    .IgnoreCase = true
    .Global     = false
  End With

  sfdcmd = Q(sfdcmd) & " /r " & Q(ClickData.func.sourcetab.path)
  For Each file In ClickData.func.sourcetab.selected_files
    If Not file.is_dir Then
      Set folder = regex.Execute(file.name)
      If folder.Count = 1 Then
        rencmd = "Rename " & Q(file.name) & " TO " & Q(folder.Item(0).Submatches(0) + "\" + file.name)
        DOpus.OutputString file.name + "|" + folder.Item(0).Submatches(0)
        DOpus.OutputString rencmd
        DOpus.OutputString "--------"
        ClickData.func.command.RunCommand rencmd
        sfdcmd = sfdcmd & " " & Q(folder.Item(0).Submatches(0))
      End If
    End If
  Next
  DOpus.OutputString sfdcmd
  WshShell.Run(sfdcmd)
End Function

Function Q(s)
  Q = """" & s & """"
End Function

2014-02-09 23_39_40.png

Get your RegExp correct and you can select every file and just hit the button.

BTW, you want to post your RegExp you're using on those commands?

Because I'm quite sure you could reduce the number commands you'd require.

eg. From this image here, you seem to be using 3 different commands presumably with RegExp Rename commands along these lines:

Rename REGEXP PATTERN "(.+)(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})(-|\s)(\d{6})\.(.+)" TO \1\\\0

Whereas, a single command with the following RegEx should cover all 3 types of filenames:

Rename REGEXP PATTERN "^([^\.-]+).*" TO \1\\\0

Panorama.jpg
"I will not follow where the path may lead, but I will go where there is no path, and I will leave a trail." - Muriel Strode, 1903
« Last Edit: February 15, 2014, 01:17 AM by 4wd »

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
Up front: sorry for the delay. Watching Olympics yesterday   :)

Currently I am still with the latest v10 of Opus, waiting for the release candidate or final, which will come soon I guess.

I have a number of items in my context menu, creating a Filenamed folder to copy or to move to.

For files with
date-time
seq.nbr-date-time
date  only
seq.nbr-date

above files are often a number screenshots, e.g. of program settings, or actions, etc.

and for files without date


=
[attachthumb=#]
=

The regex things, they work fine.

SetFolDate works fine with the existing regex.

I tried with the other options, non-regex, but it did not work out there.

=
http://s528.photobucket.com/user/phwul/media/SetFolDate/SetFolDateNew-10022014120123_zpsbebae824.mp4.html
=

1st regex: Create Filenamed Folder to MOVE to... (Date+Time)
Rename REGEXP PATTERN "(.+)(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})(-|\s)(\d{6})\.(.+)" TO \1\\\0
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}

2nd regex: Create Filenamed Folder to MOVE to... (##-Date+Time)
Rename REGEXP PATTERN "(.+)(-|\s)(\d{2}|\d{3})(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})(-|\s)(\d{6})\.(.+)" TO \1\\\0
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}

3rd regex: Create Filenamed Folder to MOVE to... (Date Only)
Rename REGEXP PATTERN "(.+)(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})\.(.+)" TO \1\\\0
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}

4th regex: Create Filenamed Folder to MOVE to... (##-Date Only)
Rename REGEXP PATTERN "(.+)(-|\s)(\d{2}|\d{3})(-|\s)(\d{6}|\d{8}|\d{2}-\d{2}-\d{4})\.(.+)" TO \1\\\0
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}

=
non-regex

1st one: Create Filenamed Folder to MOVE to...
Copy MOVE CREATEFOLDER "{dlgstringS|Name of Folder to move to...|{file$|noext}}"
Select ALLDIRS
"F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}


the
         Select ALLDIRS
          "F:\Directory Opus\SetFolDateFM.exe" /r {ss} {allfile}

does not work here...

I have not yet testen your vbscript..  cause I am not sure..
Do you suggest I create this in the rename panel?
Actually I donot want to have too many buttons, reason why it is in the context menu with me.
Personally I think context menu items are much 'easier to work with' than buttons.

Anyway..

thanks for yr help!
=


« Last Edit: February 10, 2014, 11:34 AM by dcwul62 »

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336

In the above ( TO \1\\\0 )  the  '\0'  is the foldername.
can this be used as a variable?
I don't know...  :(

together with set fn and select $fn , like in
http://resource.dopus.com/viewtopic.php?t=15624&p=82452
or
http://resource.dopus.com/viewtopic.php?p=46176

Ah well, as said, I don't know..

dcwul62

  • Supporting Member
  • Joined in 2013
  • **
  • Posts: 336
By the way, do you know a way to batch update folderdates based on a date in the foldername?
Like:
FolderNameXYZ 10-02-2014        with folder modified date 01-12-2013

then folder modified date to be updated to 10-02-2014

This is a regular thing, sofar I always updated it manually using an attribute changer.
(requires a number of clicks and is one by one)

=

Original address: https://www.donationcoder.com/forum/index.php?topic=35881.0