Option: restore parent folder date after deleting (or moving from it) content

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Option: restore parent folder date after deleting (or moving from it) content

Post by *Fla$her »

When using reverse date sorting (my default), deleting contents inside folders causes them to end up on top, although there is no benefit in this, on the contrary, it's confusing, harms the visual assessment and structuring of viewed or processed content (media and documents) and you often have to spend extra time checking useful changes (creating/modifying).

The suggested option will fix this problem. For example: RestoreDirDateAfterDeletingContent=0/1
Last edited by Fla$her on 2024-04-17, 13:54 UTC, edited 2 times in total.
Overquoting is evil! πŸ‘Ž
User avatar
Dalai
Power Member
Power Member
Posts: 9418
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (SΓΌdthΓΌringen)

Re: Option: don't update the folder date when deleting (or moving from) content

Post by *Dalai »

It's not TC which updates directory timestamps but Windows or the underlying file-system. As soon as directory contents are changed (file added, removed) the timestamp changes. Check with other file-managers, Explorer or CMD and you will see the same thing.
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: don't update the folder date when deleting (or moving from) content

Post by *Fla$her »

It doesn't matter. We have the CopyDirTimeStamp and CopyAllTimes options that control the change of timestamps when copying, the same can be done for folders when deleting/moving from them, restoring the previous date, especially since TC has its own deletion mechanism when Win95Delete=0 and VistaDelete=0.
Overquoting is evil! πŸ‘Ž
User avatar
petermad
Power Member
Power Member
Posts: 14839
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Option: don't update the folder date when deleting (or moving from) content

Post by *petermad »

Hmm, it seems to me that the title of this topic should rather be: "Restore folder date after deleting (or moving) content".

It could be nice as an option, but should maybe also include adding files.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: restore parent folder date after deleting or moving content

Post by *Fla$her »

OK. Changed.
but should maybe also include adding files.
If the copy and move commands had such an option for a target folder, then it would make sense. But saving the date of any folder for any changes is no less a problem than I described.
Overquoting is evil! πŸ‘Ž
User avatar
ZoSTeR
Power Member
Power Member
Posts: 1014
Joined: 2004-07-29, 11:00 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *ZoSTeR »

Β 
Full support.

I even wrote a script to prevent that at least for deleting files: post
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *Fla$her »

I also did it on AutoIt, but not so much for the button as for reassigning Del and Shift + Del for the current delete command, restoring the date so far only in regular folders.
DeleteWithSavingParentDirDate.au3

Code: Select all

;β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” AU3 β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
;    Purpose: Delete content with saving parent folder date
;     Advice: Bind em_DeleteWithSavingParentDirDate to Delete and Shift+Delete
; Parameters: %S1:~,0
;β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
#NoTrayIcon
$hWnd = WinGetHandle('[ACTIVE]')
If DllCall('user32.dll','int','GetClassName','hwnd',$hWnd,'str','','int',4095)[2] <> 'TTOTAL_CMD' Then Exit
$sPanel = _GetInfo(1000)
Global $sCount = _GetInfo(1004 + $sPanel), $Type = 'Post'
If $sCount = 0 And _GetInfo(1008 + $sPanel) = 1 And _GetInfo(1006 + $sPanel) = 0 Then Exit
$Dir = StringRegExpReplace(ControlGetText($hWnd,'', _GetInfo(8 + $sPanel)),'\\[^\\]+$','')
$IsDir = FileExists($Dir & '\')
If $IsDir Then $Type = 'Send'
If StringLen($Dir) > 2 And $IsDir = 1 Then
   If $sCount = 0 Then $sCount = 1
   $MDate = FileGetTime($Dir, 0, 1)
   Global $DSize = DirGetSize($Dir, 1), $iCount = $DSize[1] + $DSize[2], $NDate, $LDate, $lCount
   $rCount = $iCount - $sCount
EndIf
DllCall('user32.dll','int',$Type & 'Message','hwnd',$hWnd,'uint',1075,'wparam',908,'lparam',0)

If IsDeclared('MDate') Then
   While $rCount < $iCount
      Sleep(500)
      $DSize = DirGetSize($Dir, 1)
      $iCount = $DSize[1] + $DSize[2]
      If $iCount = $lCount Then ExitLoop
      $lCount = $iCount
   Wend
   $NDate = $MDate
   While $LDate <> $NDate
      $LDate = $NDate
      FileSetTime($Dir, $MDate)
      Sleep(1000)
      $NDate = FileGetTime($Dir, 0, 1)
   Wend
   If $MDate <> $NDate Then FileSetTime($Dir, $MDate)
   Sleep(1000)
   If $MDate <> FileGetTime($Dir, 0, 1) Then FileSetTime($Dir, $MDate)
EndIf

Func _GetInfo($i)
   Return DllCall('user32.dll','handle','SendMessage','hwnd',$hWnd,'uint',1074,'wparam',$i,'lparam',0)[0]
EndFunc
It's not recommended to create or modify items in a folder during a background operation.
Overquoting is evil! πŸ‘Ž
andry81
Member
Member
Posts: 104
Joined: 2018-11-22, 19:17 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *andry81 »

Just a suggestion, add a local configuration file for a file system components. For example, to avoid apply it everywhere, instead add file `.wincmd.ini` into a directory you want to alter the behavior:

Code: Select all

[Configuration]
RestoreDirDateAfterDeletingContent=1
RestoreDirDateAfterDeletingContent_RecurseSubdirs=1
RestoreDirDateAfterDeletingContent_DirGlobbing="MyDir*"
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *Fla$her »

andry81 wrote: ↑2024-05-13, 11:58 UTC For example, to avoid apply it everywhere,

Code: Select all

RestoreDirDateAfterDeletingContent_RecurseSubdirs=1
Do you want the behavior when selecting from branch mode and search results to be different from the normal folder mode? Why is it necessary?
It's better if one option will regulate all parent dirs in which the disappearance occurs.
Overquoting is evil! πŸ‘Ž
andry81
Member
Member
Posts: 104
Joined: 2018-11-22, 19:17 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *andry81 »

Fla$her wrote: ↑2024-05-13, 16:44 UTC
andry81 wrote: ↑2024-05-13, 11:58 UTC For example, to avoid apply it everywhere,

Code: Select all

RestoreDirDateAfterDeletingContent_RecurseSubdirs=1
Do you want the behavior when selecting from branch mode and search results to be different from the normal folder mode? Why is it necessary?
It's better if one option will regulate all parent dirs in which the disappearance occurs.
Just suggest a local config file to override a global config.
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *Fla$her »

andry81 wrote: ↑2024-05-13, 23:50 UTC Just suggest a local config file to override a global config.
I don't understand, are you talking about the RedirectSection key? How does this relate to my question?
Overquoting is evil! πŸ‘Ž
andry81
Member
Member
Posts: 104
Joined: 2018-11-22, 19:17 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *andry81 »

Fla$her wrote: ↑2024-05-14, 00:13 UTC
andry81 wrote: ↑2024-05-13, 23:50 UTC Just suggest a local config file to override a global config.
I don't understand, are you talking about the RedirectSection key? How does this relate to my question?
Local config enables it for a specific directory instead to add it to the global config, where it would be enabled for all directories, which is definitely is a bad solution.
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *Fla$her »

I asked, "Why is this necessary?" in relation to _RecurseSubdirs, not _DirGlobbing.
Overquoting is evil! πŸ‘Ž
andry81
Member
Member
Posts: 104
Joined: 2018-11-22, 19:17 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *andry81 »

Fla$her wrote: ↑2024-05-15, 06:33 UTC I asked, "Why is this necessary?" in relation to _RecurseSubdirs, not _DirGlobbing.
Because the recursivity or nesting is a part of each directory. You can use multiple levels, for example: Years/Months/Days
So you have to restore the whole directories path.

Or you mean why not use recursion by default? I think it should be optional and does apply to the directory where the local config file is placed.
Fla$her
Power Member
Power Member
Posts: 2351
Joined: 2020-01-18, 04:03 UTC

Re: Option: restore parent folder date after deleting (or moving from it) content

Post by *Fla$her »

Once again: pseudo-recursion during deletion is possible only for files selected in DirBranch mode. That's why I asked about your desire to separate the behavior (given the additional key) of 3 modes and pointed out that this separation doesn't look right, safe and expected for many users, i.e. I wouldn't approve of this key with _RecurseSubdirs.
The real recursion concerns considering the entire depth of folders, and since deletion doesn't have file filtering, then there can be no recursion as such.
Overquoting is evil! πŸ‘Ž
Post Reply