Listb - a file explorer/viewer inside the console window

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#16 Post by misol101 » 16 Jun 2016 16:18

Updated the archive and repo again, possibly for the last time unless some major bug is found.

The following was changed:

l.bat:
1. Now uses thefeduke's solution of finding extendlistb.bat in a PATH folder, thus no need to use absolute path
2. The current width/height of the window is now used instead of forced width of 80 and forced height of 50.
3. If width or height set explicitly, then the original width/height is restored when the script exits
4. Mimimum height of 50 is used unless set explicitly

listb.bat/extendlistb.bat:
1. On startup, listb now calls SETVIEWERS in extendlistb.bat, to possibly change the viewers/action when pressing RETURN, e, and p. Thus, there is no longer any need to edit listb.bat directly to change these.
2. Backspace key(^H) now has same functionality as < key. The old ^H function in extendlistb.bat is now ^L instead.
3. Mouse presses where the column is bigger than 127 now works (up to 255) (a change in cmdwiz.exe was needed for this, so cmdwiz.exe must also be replaced)

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#17 Post by misol101 » 16 Jun 2016 16:29

By the way, I ran this script on a friend's computer where it was really slow. Turns out it was the antivirus running in some kind of sandbox mode, slowing down the execution of my external programs gotoxy.exe and cmdwiz.exe horribly. It made this script slow, and even more so in the case of my realtime graphics stuff, such as mov2txt and cmdgfx.

So just in case these things move like syrup, don't blame me, blame your antivirus (probably) :mrgreen:

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Listb - a file explorer/viewer inside the console window

#18 Post by aGerman » 19 Jun 2016 05:47

So just in case these things move like syrup, don't blame me, blame your antivirus (probably) :mrgreen:

(Probably off-topic in this forum but maybe useful for you ...)
A few years ago I found that adding "Extended Properties" to your app can influence the way antivirus software handles it. It can even protect it from detecting it as "false positive". Just add a resource file to your project.
dummy.rc

Code: Select all

/*
https://msdn.microsoft.com/en-us/library/windows/desktop/aa381058(v=vs.85).aspx
*/

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define APP_VS          1,0,0,0
#define APP_VERSION     "1.0.0.0\0"
#define APP_BUILD       "January 2016\0"
#define APP_DEVELOPER   "John Doe\0"
#define APP_COPYRIGHT   "© 2016 John Doe\0"
#define APP_NAME        "DUMMY\0"
#define APP_FILENAME    "dummy.exe\0"
#define APP_COMMENT     "dummytext\0"


LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US

VS_VERSION_INFO    VERSIONINFO
  FILEVERSION      APP_VS
  PRODUCTVERSION   APP_VS
  FILEFLAGSMASK    VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
  FILEFLAGS        VS_FF_DEBUG|VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE
#else
  FILEFLAGS        0x0L  // final version
#endif
  FILEOS           VOS_NT_WINDOWS32
  FILETYPE         VFT_APP
  FILESUBTYPE      VFT2_UNKNOWN // not used
{
  BLOCK "StringFileInfo"
  {
    BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
    {
      VALUE "Build",            APP_BUILD
      VALUE "Comments",         APP_COMMENT
      VALUE "Developer",        APP_DEVELOPER
      VALUE "FileDescription",  APP_COMMENT
      VALUE "FileVersion",      APP_VERSION
      VALUE "InternalName",     APP_NAME
      VALUE "LegalCopyright",   APP_COPYRIGHT
      VALUE "OriginalFilename", APP_FILENAME
      VALUE "ProductName",      APP_NAME
      VALUE "ProductVersion",   APP_VERSION
    } // BLOCK "040904E4"
  } // BLOCK "StringFileInfo"
  BLOCK "VarFileInfo"
  {
    VALUE "Translation", 0x0409, 0x04E4
  } // BLOCK "VarFileInfo"
}


Just customize the macros at the beginning ...

Whenever I share one of my tools (which rarely happens) I take care that I recompiled it with a .rc file like that.

Regards
aGerman

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#19 Post by misol101 » 19 Jun 2016 15:48

Thanks aGerman, looks worth looking into.

I suppose the resource file might make the final executable look more "normal" for the Windows environment.

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Listb - a file explorer/viewer inside the console window

#20 Post by aGerman » 19 Jun 2016 16:13

Sort of. I was more facing the antivirus though. I noticed that small apps (less than 5 or 6 KB) are more often considered as false positives. Appending those extended properties leads the program file to grow (which does neither mean that it takes longer to load the process nor that it slows down its execution in any way). The fact that these properties are appended at the end of the binary code let me assume that antivirus software does also check the end of the program file if it searches for virus signatures. In that case it will find plain text rather than machine code. Furthermore I don't think that virus coders would mark their malware with the developer name, copy right or purpose of the software :lol:

Regards
aGerman

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#21 Post by misol101 » 23 Jun 2016 06:22

The archive (as well as the gotoxy archive) was updated.

Added support for adaptive columns, which means that if there are less files in the folder than what fits within the number of columns set, then the number of columns is decreased to fit the number of files.

To turn on adaptive columns, specify a negative value as columns to listb.bat. The value then represents the MAXIMUM number of columns that the adaptive algorithm will allow per screen.

l.bat now uses adaptive columns per default.

Adaptive columns can also be turned on/off by pressing '0' while running.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#22 Post by misol101 » 24 Jun 2016 08:55

Archive updated, I have added dividing lines between columns.

The lines are on by default if using the latest extendlistb.bat (when running l.bat), and off if using listb.bat only.

If you have your own extendlistb.bat, you can turn on dividers by adding the following line after the label :SETCOLORS

set HDIV=1

Or, alternatively, edit listb.bat, search HDIV,and change the value from 0 to 1.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#23 Post by misol101 » 24 Jun 2016 14:43

Alright, one more update. Keep thinking it's the last one. Probably not I guess :)

If files/folders are too long for their column, this is now marked at the end of the name with a ~ character.


Also, I decided to turn on dividers in listb.bat (I got used to them now :) ). This means it's the opposite now to the previous post, i.e if you *do not* want the dividers, either write

set HDIV=0

in extendlistb.bat after the label :SETCOLORS, or find the line in listb.bat and change it to 0.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#24 Post by misol101 » 24 Jun 2016 14:58

Whoops, the link in the first post was not pointing to the new archive. Fixed now!

If you tried to download listb.zip (or gotoxy.zip) earlier today and didn't see the expected dividing lines, please re-download.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#25 Post by misol101 » 25 Jun 2016 04:48

Archive was updated again, following the long and somewhat confused discussion here: http://www.dostips.com/forum/viewtopic.php?f=3&t=7242&p=47374

Basically, when pressing 'i' or 'j' to launch a file, com/exe/bat/cmd files runs synchronously and in the same cmd window (as before), whereas all other file extensions now run asynchronously.

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#26 Post by misol101 » 05 Jul 2016 19:59

Another archive update (see top post for link).

Two fixes:

1. Small but annoying bug causing adaptive columns to sometimes choose too many columns

2. Due to help from aGerman, launching programs with 'i' and 'j' now distinguishes between windows executables and console executables. They are launched differently, following the discussion at viewtopic.php?f=3&t=7242&p=47374

(more on (2) in the gotoxy thread)

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#27 Post by misol101 » 30 Jul 2016 18:35

Archive update.

Added support for "detailed mode", which in addition to file name also lists date/time and file size (it is actually exactly the difference between running "dir /b" and "dir").

To switch to/from details mode, press '+' while running.

In details mode, there is always only one column. If you set the number of columns with keys '1-9', you leave details mode.

Running in "details mode" is slower and fills up the environment variable space a lot. It is not recommended for folders with 1000+ files.

There is currently no argument that will put listb in "details mode" on startup. If you prefer to always use it on startup, one way of doing it is to uncomment the line in extendlistb.bat that says SET DETAILS=1

misol101
Posts: 475
Joined: 02 May 2016 18:20

Re: Listb - a file explorer/viewer inside the console window

#28 Post by misol101 » 02 Aug 2016 06:02

Small archive update.

I didn't really think about this before, but the DIRCMD variable may cause issues.

Strangely enough, starting a switch for "dir" with /- does not mean "don't use this switch if set in DIRCMD", it actually means "flip whatever setting is in DIRCMD" :!: Isn't that a bit stupid?

So, assume my DIRCMD is empty. In my script I want to use "dir", but I don't want for example the /S switch to be used. So in the script I do "dir /-S" thinking this will prevent any stupid setting in DIRCMD, but no, this actually enables the /S switch! If, on the other hand my DIRCMD would have contained /S, then "dir /-S" would have disabled that switch.

So the only safe way of doing this (which is what the archive update is), is to save the old DIRCMD, then clear DIRCMD, then do the dir command without any /- switches (except for possibly /-C), then restore DIRCMD.

Post Reply