sfk list - sort directories first

2014-01-18
2014-01-18
  • thomas kellerer

    thomas kellerer - 2014-01-18

    Hello,

    when using

    sfk list -dir . -file .txt -sort
    

    all txt files in all subdirectories will be listed. This is fine, but I'd like to have the output start with the subdirectories and not sort them together with the filenames of the current directory.

    The above would print something like

    a.txt
    b\c.txt
    c.txt
    d\e.txt
    

    I would prefer to first show all directories then all the files

    b\c.txt
    d\e.txt
    a.txt
    c.txt
    

    similar to the DIR option /OG ("Directories first") in Windows.

    Is there a way to do this? I tried it with chaining the list command to first show all directories and then list the files:

    sfk list -justdirs -sort -dir . +list
    

    but that simply displays all directory names, not the content of each directory.

     
  • stahlworks

    stahlworks - 2014-01-18

    you may try

    sfk list -sort -dir . -file .txt +filter -+\ +select -sort -nosub -dir . -file .txt
    

    or a bit shorter

    sfk list -sort . .txt +filt -+\ +sel -sort -nosub . .txt
    

    explanation:
    - the filter will strip all normal filenames not being in a sub folder, for the first output
    - select (instead of list) starts a new command that does not reuse filenames from the previous
    - option -nosub lists only the files in the current folder, for the second output

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks