Lately I was working on a sub-directory to test more advanced wildcards. But things run a bit 'out of hand', so I scripted a full front-end for grub4dos' internal function 'ls': https://github.com/deomsh/LIST.G4B
This script can be used as a replacement for 'ls', output should be the same, but with a few modifications:
- pager is working, I made my own pager (not working on grub4efi)
- empty directories are greyed out (except on NTFS only, not possible to discriminate between empty directories and zero-byte files on this file-system. I choose to show zero-byte files as directories - 'ls' can SHOW the difference)
- sub-directories can be parsed too (with the well known switch '-s')
- colors can be set on file-names, file-extensions, not-empty directories, empty directories and on sub-directories
I took idea's for switches from the Linux/ Unix BASH command-line, MS-DOS 7.1 and Windows 10 CMD.
Starting with LIST.G4B is easiest without any other parameter, small-help will show up. The small-help will also be shown if an error is made about the actual commands (an idea steve6375 gave me when I published TEXTSTAT.G4B). See first print-screen:
There are six basic forms of output. The two 'wide' outputs are self-adjusting to the actual graphics mode: number of column's between 5 and 12 (I am afraid 320x240 or 200? is not fully supported with 'wide'). See next six print-screens.
BTW escaped spaces '\ ' are only visible in the default 'ls'-mode, in al other modes removed.
Following wildcards are supported: '?' and multiple '*' in file-names and file-extensions. In directories only ONE '*' at the end of the LAST directory-name in the PATH. Default LIST.G4B is not case-sensitive, but this can be altered with switch '-case'. See next three print-screens:
Also sorting is added. There are three sorting possibilities: name, extension and file-size. Also 'grouping' on directories/ files is available. See next print-screen for an example:
BTW my second programmer-son helped me a lot. First with the algorithm of 'selection sort' - which was quite easy because I (re)invented my own pointers (24 bits for memory address of files and 8 bits for their length).
Later he insisted I had to try 'quick sort' too, which should be faster in theory.
But because I pre-sorted in 35 'buckets', in most cases selection sort is still faster (number of 'swaps' seems to be best with selection sort - I found 'break-even' in case of about 15 pointers in a bucket). This sorting method also has the virtue the sorted file is immediate available for echoing, so output is more fluently.
However with switch '-qs' quick sort is available too.
With switch '-n' the number of folders and files is counted and echo'd at the end (with -nq exported to a set-variable). See next two print-screens. On the second print-screen can be seen the file names with leading spaces can not be displayed with sorting (they are NOT according to the Microsoft's Long File Name specification anyway).
BTW ment is the folder: ' LFN Starting Spaces in Total Commander'
With switch '-e'/ '--e' only empty directories are displayed/ not displayed. With switches '-d'/ '-f' directories/ files only. Colors can be set with switch '-col:NXDES' (for details see the 'Help'). Next two print-screens give examples (empty folders brown, not-empty folders yellow and device+path+sub-directories high-white:
BTW it is also possible to set colors with variable 'lscol', active until grub4dos command-line is left.
Another possibility is to filter on Short File Names/ Long File Names, but only as far 'ls' is showing them. So no truncated file names here. See next print-screen for some examples:
Inspired by the '-e' switch from the BASH command-line I added multiple extensions: switch '-me'. Also multiple directories ('-md') OR multiple subdirectories ('-ms'). Can all be used with and without switch '-s'. See next three print-screens:
For the more advanced users (if any) my implementation of redirecting, piping and adding other commands after 'FILE'. This is more complicated, but there are some instructions in the Help. A few examples can be seen in next print-screen:
About the support of grub4efi: although (almost fully supported) quite unstable, even with switch '-mdbase:startsector' to use a free memory area on grub4efi. See last print-screen: