Example use case:
Let's say, I have a bunch of random archives which I-got-from-who-knows-where-from and may-have-got-who-knos-what-timestamps.
By design, an archive may have its external timestamp reflecting the time it was saved, downloaded, etc.
What if:
I wish an archive to be kept under its content's date (i.e. having a timestamp reflecting the most recently modified content within).
A user-button:
Code: Select all
TOTALCMD#BAR#DATA
em_redate_archives_by_content
TOTALCMD64.EXE,41
PowerShell: Redate archives by content
0
-1
Code: Select all
[em_redate_archives_by_content]
cmd=pwsh -c "%commander_path%\Plugins\app\PowerShell\redateArchivesContent.ps1"
Code: Select all
$lap = [system.diagnostics.stopwatch]::StartNew()
# binary
$env:path += ";$env:commander_path\Plugins\app\7zip"
# define files
$zip = @('*.zip','*.7z','*.epub')
$files = Get-ChildItem * -file -force -include $zip
# process
foreach ($file in $files) {
$i = $file.FullName
$name = $file.Name
Write-Host "processing..." -f Yellow
Write-Host "full : $i" -f Cyan
Write-Host "name : $name" -f Cyan
# 7zip list output date pattern
$date = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
$array = (&7z l $i | Where {$_ -match $date}).substring(0,19)
Write-Host "measure..." -f Yellow
$min = ($array|Measure-Object -Min).Minimum;"min : $min"|Write-Host -f Green
$max = ($array|Measure-Object -Max).Maximum;"max : $max"|Write-Host -f DarkCyan
(Get-Item $i).LastWriteTime = Get-Date $max;''
}
$lap.Stop();'';"timer: {0:mm}:{0:ss}.{0:fff}" -f $lap.Elapsed|Write-Host -f Cyan;sleep -s 5
- Since TC 11.50 betas Mr ghisler(Author) is trying their best to integrate 7zip, but I don't have time to recognize how it works in practice, so the above script implies using standalone 7zip.
- The script in no way modifies the archives' content (they will digitally remain the same), only their external timestamps.
- Given script edition implies it will process *.zip, *.7z', and *.epub archives. Feel free to add there other zip-based archives from which 7zip l is capable of extracting the adequate tramp stamps (*.docx, *.xlsx. etc).