Quantcast
Channel: Total Commander
Viewing all articles
Browse latest Browse all 4082

Plugins and addons: devel.+support (English) • Delete files with keeping the folder date

$
0
0
 
Not really a plugin/addon but it might be useful to somebody:

I often delete specific files in my download subfolders (via Ctrl+B / File-Search) but this updates the modified date of the parent folder and thereby messing up the sort-by-date order.

This a little PowerShell script to avoid that:

Code:

#TC Button<#--------------------snip------------------TOTALCMD#BAR#DATApowershell.exe-ExecutionPolicy remotesigned -Command "& {& """${env:COMMANDER_PATH}\Tools\DeleteWithDateRestore.ps1""" -ListFile '%UL'}"C:\WINDOWS\System32\imageres.dll,322Delete with Date Restore-1--------------------end-snip----------------#>#TC Button Endparam(    [Parameter(Mandatory=$True)]    [ValidateNotNullOrEmpty()]    [string]$ListFile)$files = Get-Content -LiteralPath $ListFile$answer = Read-Host -Prompt "Delete $($files.count) files? (y)"if (@("y","j") -contains $answer){    foreach ($file in $files)    {        if (Test-Path -LiteralPath $file -PathType Leaf)        {            $item = Get-Item -LiteralPath $file            $parentLastWriteTime = $item.Directory.LastWriteTime            $item.Delete()            $item.Directory.LastWriteTime = $parentLastWriteTime        }    }}else{    #throw "Abort"    return}
Save as "~TC-Path~\Tools\DeleteWithDateRestore.ps1" or adjust the path to your liking and copy&paste the snip part as a button.

Select the files to delete and hit the button.

Statistics: Posted by ZoSTeR — 2024-01-28, 18:05 UTC



Viewing all articles
Browse latest Browse all 4082

Trending Articles