Jump to content

List files to array and sort them by date


Go to solution Solved by JohnQSmith,

Recommended Posts

oldest/latest, ascending/descending.  Two ways to say the same thing, no?

#include <Constants.au3>
#include <Array.au3>

$sSFK = @ScriptDir & '\sfk.exe'
$sDir = 'C:\Scripts'
 
;try each of these below

$sCommand = 'list -late -notime'
;~ $sCommand = 'list -old -notime'

Local $hRun = Run(@ComSpec & ' /c "' & $sSFK & '" ' & $sCommand & ' ' & $sDir, @ScriptDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $sOut = ''
ClipPut('"' & $sSFK & '" ' & $sCommand & ' "' & $sDir & '"')
While 1
    $sOut &= StdoutRead($hRun)
    If @error Then ExitLoop
WEnd
$sOut = StringReplace($sOut, @CRLF, '', -1)
Local $aRet = StringSplit($sOut,@CRLF, 1)

_ArrayDisplay($aRet)
Link to comment
Share on other sites

  • Solution

C:\> sfk sort
sfk ... +sort
 
   sort text lines, case insensitive by default.
   requires a previous command producing text output.
 
   options
      -case        case sensitive text comparison
      -rev[erse]   reverse sorting order
 
   examples
      sfk filter csv.txt +sort
         print sorted contents of csv.txt
      sfk filter csv.txt +sort +view
         shows output with the dview GUI tool

So change the command to...

sfk list -flattime . +sort -rev

Also look at...

sfk dumphelp
Edited by JohnQSmith

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Link to comment
Share on other sites

  • 8 years later...

I am trying to repeat the code with DIR by Spiff59. But I have a problem with Russian characters (row 3). Can this be solved?

ar93E3e.jpg

I assume there is an encoding problem here. Need WIN 1251, but using old DOS 866 (maybe).

 

Edited by mike2003
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...