> Coule you provide an example of how that works? (for others...)
Sure.
First of all there are ways to do much of this in es.exe directly. But not everything can be done in everything (yet?), so knowing how to use es.exe and PowerShell together is a very useful skill set.
Here's a sorted datetime for finding all the copies of 7z on your system. BTW, this is a good idea to try, as there were bugs/security issues in previous versions of 7Zip and it's astounding how many programs load 7z privately.
es 7z.exe -dm -sort-datemodified-ascending
If we didn't know how to do it the we could use PowerShell to "help" like this:
es 7z.exe | Get-ChildItem | Sort-Object LastWriteTime | Select-Object Length,LastWriteTime,Name,Directory
es 7z.exe | dir | Sort LastW*e | Select Len*,LastW*E,Name,Dir*E # alternative with less typing
That Get-ChildItem might seem unnecessary, given that es.exe is already sending the filenames, but the issue is that PowerShell can do far more with "Objects" than with simple strings.
By sending the es.exe output through Get-ChildItem we send an OBJECT down the pipeline. Objects require no parsing, so we can manipulate the MEMBER PROPERTIES (or even methods) directly and easily
After that, the rest is obvious: Get the file, sort, select the properties we want to display (or pass to another command.)
Selecting the properties is optional, but in most cases like this you will prefer it to outputting either the entire "object" (all properties" or whatever is the DEFAULT formatted display of that object type. However, it's YOUR option.
Another idea that es.exe doesn't do (AFAIK) is to find "File versions", but PowerShell can do this easily, and once we know the patterns above we can enter the command easily as well.
Code: Select all
es 7z.exe | dir | Sort LastWriteTime | Select -expand VersionInfo
ProductVersion FileVersion FileName
-------------- ----------- --------
18.05 18.05 C:\ProgramData\Local\Julia\bin\7z.exe
18.05 18.05 C:\util\7-Zip\App\7-Zip64\7z.exe
18.05 18.05 C:\util\7z.exe
18.05 18.05 C:\ProgramData\chocolatey\tools\7z.exe
18.05 18.05 C:\Program Files\Unity\Editor\Data\Tools\7z.exe
C:\ProgramData\chocolatey\lib\openssh\tools\7z.exe.ignore
9.20 9.20 C:\Users\A469526\Downloads\CSScriptNpp.Updater\7z.exe
There were a lot more, and you can see that some have no versions or that 9.20 that snuck through and I need to replace.
What's new here? Adding "-expand" to Select-Object for the VersionInfo. VersionInfo itself is a "complex object" so simply selecting it won't give good results. We need to "EXPAND" out the VersionInfo properties.
Adding the datetime from the main FileInfo object to the VersionInfo object is a bit trickier (though not too difficult).
It's on my "to do" list so if there is interest I can work that out and post it in a followup.