Using a File browser in Batch files to place

May 29, 2010 at 10:03:31
Specs: DOS
I'm looking for a DOS file browser (file selector / request file) that will place the result in a environmental variable.
I tried WBAT but is not what I'm looking for.
Then I found an utility named BATCHSEL.ZIP but doesn't work correctly under DOS 6.22.
i.e.: BATCHSEL *.ROM Select_a_file SET SELECTEDFILE=%%f
doesn't place the value of %%f in the ENV.

So, im looking for an utility like batchsel...

can you help me?

very very thanks


See More: Using a File browser in Batch files to place

Report •

#1
May 30, 2010 at 01:31:48
I can't suggest any alternate file browsers but there may be a work around:

batchsel *.* Select_a_file_to_view   ECHO C:\ARG.BAT %%f > C:\TEMP.BAT
ECHO SET FILE=%%1 > C:\ARG.BAT
C:\TEMP.BAT

I used "c:\" because batchsel seems to change the directory, you can change the names of the temporary batch file as desired/prefix with @.


Note: I tested it quickly under XP, but I'm pretty sure it will work under DOS because I have done things like that under DOS.

Warning If arg.bat or temp.bat exist in c:\ they will be overwritten!


Report •

#2
May 30, 2010 at 12:08:46
Thanks for your interest, I had already thought about it, but there is a problem: this batch should be run from CD-Rom, then it would not work because it is write protected, for now I use %TEMP% for redirect the output of ECHO, but this way only works if the computer is booted from HD, if I boot the computer directly from CD then it does not work.

Report •

#3
May 30, 2010 at 16:10:49
Yeah, I didn't think of that, I guess your not loading a ramdrive either, so it looks like batchsel may be a bust. I cracked it open in a hex editor and saw if forks <command> over to "comspec /c"(hence the variable issues).

Can't be any more help I'm afraid, I hope you figure it out.


Report •

Related Solutions

#4
June 1, 2010 at 13:55:52
I wrote a program which seems to do exactly what you need (at least as far as i understood your problem)

Unfortunataly i had to make the experience in simalar threads, that my postings simply vanished after a few days. So i'm not shure whether it is desired to recommend self-written software in this forum at all.

Should you still be interested, please let me know.


Report •

#5
June 3, 2010 at 06:02:50
sure, I'm still interested!
where I can download your application?
you can also send me it as attachment to my email address registered to computing.net.

thanks!


Report •

#6
June 3, 2010 at 08:01:24
Go to this website: http://www.bttr-software.de/products/jhoffmann/.

There you will find, among other items, a zip archive named DOSUTILS.ZIP which is actually a package of twelve more or less usefull dos utilities. One of them, SELECT.COM is intended to be something like a DOS counterpart of the standard windows file dialog. The file DOSUTILS.TXT which is also enclosed in the archive will tell you the details.


Report •

#7
June 3, 2010 at 09:44:16
thank you wiwa64!
very nice tool !

but, let me say.... how the hell it is so slow on screen refresh? =)


Report •

#8
June 3, 2010 at 13:43:07
Emmm . . . could you be a bit more specific?

Report •

#9
June 3, 2010 at 14:34:23
in browser mode moving the cursors up and down I can see the screen refresh line by line (in dosbox). on my 486 laptop when I press the down arrow on keyboard then I can see the DOS cursor redrawing the entire screen just to update a single line. I think that a better solution is to move the cursor just to the position of the line to update, while at the moment for every update the cursor move to 0,0 in order to update the entire screen!!
I know, my english is poor just like my code skills, be patience :P

Report •

#10
June 4, 2010 at 08:28:09
OK, now i get your point. However, i still disagree and dont't consider the program as slow.

You are right, the screen is updated at every cursor movement, but your proposed alternative, to just update the cursor position, would only work properly under the condition, that the list of directory entries is short enough to fit on one screen. As soon as scrolling comes into the game, things may become rather complicated.

In addition, SELECT is essentially a user interface. The user at the keyboard is the main speed limiting factor in this case. Taking this into account, i don't consider speeding-up the screen output in some special cases is worth the hassle of complicating the whole code. But this is just my very personal opinion.


Report •

#11
June 4, 2010 at 14:05:04
Thank you for your explanation and
Thanks for your interest !!

Report •

#12
August 17, 2010 at 04:10:29
Hi wiwa64 !

I came back here to ask you if you can add a new feature to your SELECT DOS tool.

I noticed two interesting parameters:
/CV switch = The user can freely change into sub-directories of this virtual root but not into its parent diretories.
/OP switch returns the full path, consisting of drive, path the short name and the type extension.

What I want to ask is:
can you add a new sub-switch (S) to "/O" so that it returns the path from the <directory that was current at program start>

E.G:
CD C:\WINDOWS
SELECT /ADFSHAR /OS /CV /T30 *.*

then I select C:WINDOWS\COMMAND\MYPROGS\HELLO.EXE
and SELECT.COM just returns:
SET SELECT=COMMAND\MYPROGS\HELLO.EXE

Simply, the /OS switch uses the <fullpath>-STRING but removing the <directory that was current at program start>-STRING from it.

PS: your SELECT is fantastic, you should do a win32 console build =)

thank you so much!
Turrican


Report •

#13
August 17, 2010 at 14:41:31
If i get you right, you want the path, relative to the directory you originally came from?

Hmmm . . . well i should have to think about this.

But at present i cannot make any promisses . . .

. . . after a first short thinking: This new sub-switch would have to include "V" sub-switch. Otherwise it could become a bit difficult. But let's see . . .


Report •

#14
August 17, 2010 at 15:36:17
yeah, it's exactly what I want =)

I need this feature 'cause the maxim DOS command-line is 127 chars (in some cases can be 103 chars), so removing un-necessary characters is a good idea :P

All you have to do is assume /CV when the user use the /OS switch, then remove the starting path string from the full path string.

Another cool feature can be a shorcut key to change the disk drive.
E.G.: Press F1 to change drive letter.
<A:> <B:> <C:> <D:> etc etc.

May be in the future..., for now I really need the /OS switch to print a relative path :P


Report •

#15
August 19, 2010 at 14:23:56
OK, i get your point and it sounds reasonable to me.

But currently i'm busy with another project which i want to complete first, so it will take some time.


Report •

#16
August 20, 2010 at 01:47:03
ok, I'll wait for you!
but, please do not forget me: P

thank you very much!!!


Report •

#17
August 21, 2010 at 04:26:01
ehi wiwa64, found a bug in select.com !! :P
it print 2 slash (in the path) if I select a file in the root of the drive!

To reproduce it:
C:\> ECHO BugFound >C:\DUMMY.TXT
C:\> CD C:\WINDOWS\COMMAND
C:\WINDOWS\COMMAND> Select /ADFSHAR /OP /C *.*

<now navigate to the root C:\ and so select C:\DUMMY.TXT>
SELECT.COM will print:
SET SELECT=C:\\DUMMY.TXT
instead of
SET SELECT=C:\DUMMY.TXT

see u
Turrican^


Report •

#18
August 24, 2010 at 13:19:05
Thank you for the bug report!

I implemented the new sub-switch and fixed the bug as well (hopefully without introducing new ones).

I chose to name the new sub-switch "R" (for relative path), it works as follows:

If the output option is "/OR" and the current directory at the moment when SELECT is terminated is still the same or below the starting directory, then the path relative to that directory will be returned, otherwise the full absolute path will be returned, just as if "/OP" had been specified. The starting directory is the one that is given as argument when SELECT is called and it is not necessarily the same as the current directory at that moment (e.g. SELECT /C ..\..\*.txt). If the "/CV" option (virtual root) is also specified, then the above condition will always be met and the starting directory will be the same as the virtual root, but "/OR" can also be used without the "V" sub-switch of "/C".

Now there is an administrative problem. It will take me some time to pack and deliver a new complete DOSUTILS package. If you are impatient you could send me an e-mail (you will find my address in the program documentation) and i could return you a pre-release of SELECT 1.3, but that's up to you.



Report •

#19
August 25, 2010 at 02:23:34
wow, I thought you needed more days before upgrading Select =)
thank you for the hotfix! :)

No, I'm not impatient, I can wait for the final version, no problem.
As soon as I download it I'll just check if everything works.

thanks!


Report •

#20
August 27, 2010 at 13:28:24
Well, i just uploaded it and it can be downloaded from here

Let me know about your experiences with the utility (and possibly the other ones in the archive as well)


Report •

#21
August 27, 2010 at 16:58:32
I just tested your new version.
I tried all the switches to verify if everything worked!

I tried Select under MS-DOS v6.22 / Windows 3.1 / Windows'98 / Windows XP.
It works great everywhere!

This is my bug report:

This is not a real problem: So, to not strain my eyes I use inverted console colors (black text on white background), as the Select does not seem to change the DOS screen mode (and even it seems to use any ANSI color) then in this condition you see a dirty print.
This is not a real bug, I've told you only for completeness. In my batch I always restore the original Console colors (gray text on black background) before use Select.
To reproduce this problem you need Windows 2000/XP/Vista/Seven.
Open a console and type 'COLOR 70', then try Select!
Under Windows 98 I use ClsColor.com to change the colors of the MS-DOS Prompt, but as it loses the screen color just by aby "clean screen" (such as CLS) then this problem does not afflict DOS/Windows9x.


Report •

#22
August 27, 2010 at 16:58:56
*NEW BUG*:
I tried:
C:\MYFOLDER\> SELECT /ADFR /OR /C /Smyenv ..\*.*
I select C:\WINDOWS\NOTEPAD.EXE
and Select will print:
SET MYTEST=INDOWS\NOTEPAD.EXE
it truncates the first character! I tried this case because I already knew that fixing the previous bug would introduced a new one like this, ehehe :)

Report •

#23
August 27, 2010 at 16:59:54
I checked the new switch / OR.
It works fine, but I doubt...

I TRIED:

C:\> select /ADFR /OR /C /T30 /Smytest WINDOWS *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select print:
SET MYTEST=SYSTEM\shell32.dll
instead of
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

so, I tried: (adding /CV)
C:\> select /ADFR /OR /CV /T30 /Smytest WINDOWS *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select print:
SET MYTEST=SYSTEM\shell32.dll
instead of
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

the same result!!!!!!!

SO, I TRIED A PARENT FOLDER AS PATH:

C:\WINDOWS> select /ADFR /OR /C /T30 /Smytest ..\ *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select print:
SET MYTEST=INDOWS\SYSTEM\shell32.dll
instead of
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

so, I tried: (adding /CV)
C:\WINDOWS> select /ADFR /OR /CV /T30 /Smytest ..\ *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select print:
SET MYTEST=INDOWS\SYSTEM\shell32.dll
instead of
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

the same result!!!!!!! (note the bug)

YOU SAID:
Note that the starting directory is the one that was specified as path argument, it is not necessarily identical to one that was current at program start.
If "/CV" is specified too, then it is identical to the virtual root and "/OR" will return the path relative to this virtual root.

well, IT's NOT TRUE! =)

In file mode "/OP" and "/OR" have no special effect. <---- what?


Report •

#24
August 28, 2010 at 01:02:31
I just tested the file mode. Now I understand what you mean by 'In file mode /OP and /OR have no special effect"' :PP

I love how the new switch works, it was just what I needed!
I especially like how you have interpreted "below starting directory/above starting directory" ("it will return the relative path / it will return the full path"). Very good!!!
It is really convenient, because it leaves you the choice (relative/full), and within batch-files it does not affect any malfunction!

But, let me tell you, you have to fix /CV (or add a new switch to /C) because, as I said, I need that the starting directory must be necessarily identical to one that was current at program start!.
This is necessary because during the execution of batch-files the Select' Path parameter can change (I use an %ENV% defined by the user as PATH parameter), while the starting/current directory in batch-files does NOT change never unless there is a CD command (change dir). I can not manipulate the file returned by Select if this is not relative to the path of the batch-file :(

Right now, if I want to use the /OR switch in order to avoid this problem I removed the PATH parameter from any string of Select in my batch-files. But it was much more elegant if the user had no need to navigate through the below directory to find the one that interested him (just like using the path parameter).

Anyway, thank you!!!


Report •

#25
August 28, 2010 at 15:02:59
C:\WINDOWS> select /ADFR /OR /C /T30 /Smytest ..\ *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select print:
SET MYTEST=INDOWS\SYSTEM\shell32.dll
instead of
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

This is indeed a bug. It seems to be somewhat related to the previous one with the duplicated backslashes and is probably not to difficult to fix(i hope) but it take some day anyway.

One thing that stroke me, is the space character between ".." and "*.*". What was your intention to spell it that way? It's bad syntax anyway, though SELECT doesn't complain about it, it just ignores the excessive second argument (the "*.*").

If your intention was "any file in the parent directory" then you should have written "..\*.*" (without space in between). But this was unnecessary as it is already the default. Only in cases like "..\*.exe" it would have made sense.

C:\> select /ADFR /OR /C /T30 /Smytest WINDOWS *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select print:
SET MYTEST=SYSTEM\shell32.dll
instead of
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

In this case i cannot see any bug! Rather there seems to be some misunderstanding about the concept of the "starting directory". You have to distinguish (up to) three diferent directories: The one that was the current one when SELECT started, in the above example this was "C:\". The starting directory is the one you told SELECT to go to, in the above example this was "WINDOWS". Inside SELECT you chose to change to the directory "SYSTEM" and selected the file "shell32.dll" in that directory. The /OR switch causes SELECT to return the path relative to the starting directory, which was WINDOWS, hence the result was correct. Upon termination SELECT returned to the previous current directory "C:\", as you did not specify /CK (keep).

Perhaps you should try to understand how SELECT interpretes the first (and only) argument:

- If it contains a wildcard character ('*' or '?') but no backslash, then SELECT assumes a search mask in the current directory which will also be the starting directory in that case.

- If it contains a wildcard character and at least one backslash, then SELECT takes the part after the last backslash as search mask and everything before the last backslash as a path where it should change to and which becomes the starting directory. Note that this part must not contain any wildcard characters.

- If it contains only backslashes but no wildcard characters, then SELECT takes the whole argument as path to change to (which becomes the starting directory) and assumes "*.*" as search mask by default.

Any excessive arguments are just silently ignored. Therefore the blank character, followed by a "*.*" has no effect at all.

BTW have you tried this?

C:\>
DIR WINDOWS *.*
You would probably get an error message like "to many arguments" or so. Perhaps i should add a message like that to SELECT as well.

Report •

#26
August 28, 2010 at 16:15:07
Thank you for your explanation!
I get your point, now.
I never figure out that the path and the mask is a single parameter.
I assumed it as 2 different parameters.
You should add some sort of feedback to the user about wrong use of switches and/or parameters!

about the /OR...I still do not understand what's the different between using "/OR /CV" and "/OR /C", testing select.com it seems there is no special effect as opposed to what you wrote in the select.com readme.txt.

So, using the path parameters (and /OR ) there is no way to force the "The one that was the current when SELECT started" instead of the PATH as the SELECT ENV return?
e.g:
C:\> select /ADFR /OR /C /T30 /Smytest WINDOWS *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select will print:
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

NEW FEATURE: Can you add a multiple mask/pattern? such as *.cpp;*.lib;*.h
I don't need this feature, but you can take a todo note for the future :P


Report •

#27
August 29, 2010 at 04:29:53
Well the difference between "/OR /C" and "/OR /CV" is as follows:

SELECT /OR /C startdir

will return the path relative to "startdir" IF (and only if) you still are in or below "startdir" when leaving SELECT. If you are somewhere else, which is possible as the /C switch allows unrestricted directory changes, then SELECT will return the absolute path (just as if /OP had been given).

SELECT /OR /CV startdir

Does basicly the same, BUT the /CV switch prevents you from breaking out of "startdir", so the conditon to return the relative path will always be met.

C:\> select /ADFR /OR /C /T30 /Smytest WINDOWS *.*
then I selected C:\WINDOWS\SYSTEM\shell32.dll
and Select will print:
SET MYTEST=WINDOWS\SYSTEM\shell32.dll

Sorry, but this one i can't reproduce. When i try it, i get

SET MYTEST=SYSTEM\shell32.dll


And with respect to the multiple pattern feature i think that the line has to be drawn somewhere. Otherwise the program which is intended to be a compact little utility risks to become totally bloated.


Report •

#28
August 29, 2010 at 11:41:54
ok.

in the meantime I'm waiting for the 1.3 bug fix


Report •

#29
August 31, 2010 at 13:28:45
Ok, a new version of the DOSUTILS including a bug-fixed version of SELECT (1.4) was just uploaded and is waiting to be downloaded.

Report •

#30
August 31, 2010 at 13:46:11
thanks, I'm just going to try it!

Report •

#31
September 1, 2010 at 12:39:13
found another bug:

SELECT /AFR /CV MYFOLDER\*.*
if the the current folder contains only files (no folders) and you are running under Windows9x or DOSLFN, then the Long name of the first file in list will be ".." instead of the real name! (no matter if you use /O, /OB or /OL). The shortname is ok.


Report •

#32
September 1, 2010 at 12:47:47
for the last post. EDIT: "if the the current folder" --> "if MYFOLDER".

btw, what about a shortcut to change the drive letter?
for now there is no way to select a file from another drive.
You could add a keyboard shorcuts with a requesto on the bottom of the screen with the choice "Select drive legger: <A:> <B:> <C:> etc".
Or you can do it in the same way as M$ do, when you are in file list mode and you are in the root of a drive, then selecting ".." will show you a list of letters so you can change to the root of another drive. For now, in you are under a root of a drive and you select "..", then Select.com will always show you the root, no effects!


Report •

#33
September 2, 2010 at 14:35:01
Oooops . . . that was indeed another bug. Just a tiny one, but nevertheless a bug. OK, fixing was not too difficult, once it was identified.

With respect to drive letter changing i am rather reluctant, even more, the more i think about it.

The problem is not the implementation of the function itself. That shouldn't be so difficult. But when changing drives a lot can go wrong. One could select a non-existing drive or a drive that exists but is currently not available because of network issues or because no medium is loaded (floppy, CDROM). All these situations have to be detected and coped with. Where to put the error message? How to prevent DOS from messing-up the screen with its "Abort, Retry, Ignore" message? etc, etc . . .

As you see from the bugs, the program code is already quite complex and it will certainly not have less bugs if i introduce another level of complexity. I prefer to have the program stable and relyable rather than adding more features. So the most i could possibly think of is allowing to specify a drive letter together with the starting directory and returning to the initial drive/path at program exit (unless /CK is specified). Then the possibly problematic situations would occur outside of SELECT's inner loop.

But who keeps you from simply changing the drive just before calling SELECT and returning afterward?

BTW where do you live or where is it where my program appears to be useful?


Report •

#34
September 3, 2010 at 03:06:46
Italy here...I'm italian.
Why do you ask it? maybe because my english is terrible :P hehe
Keep in mind that however often I write at 2:00 AM, you know how is writing at that time, I often do simple typing error :P

I'm working on a frontend for emulators, basically I'm doing my MAMECAB-like, and it mainly run emulators for DOS, since it is much easier and faster boot DOS software, than Windows one.

Thanks for the explanation, I ask you a function of "change disk" because maybe an user have the emulators on the boot partition, while the ROMs (or needed disk images) on another one.
Evenmore I use Select.com in many situations, since I'm a lover of batch-files, I often use .BAT for various situations.


Report •

#35
September 4, 2010 at 00:49:42
No, it's not your English why i am asking. It's rather that the DOS community has shrunk so much during the last ten years that i am just curious to know where those "last Mohicans" can be found. BTW English isn't my mother tongue either. I am German and i see, that my program didn't travel all that far.

I just uploaded a new DOSUTILS archive enclosing SELECT version 1.5. The double dot bug with long file names should be fixed now. In addition i added the possibility to complement starting directory specification by a drive. like e.g. SELECT /C E:\WINDOWS\*.INI If something goes wrong while trying to change the drive and/or directory the program will simply abort. If everything went well then, after completion it will return to the drive and directory it was before program start, unless "/CK" was specified.

In addition there is now a new sub-switch "/CS" solving an issue which i found problematic since long. When directory changing is enabled, then hitting the <RETURN> key while a file entry is highlighted selects that file, but when applied to a directory, it changes to that directory. So far, so well. But the consequence of that is, that you cannot select directories (e.g. as target for a copy operation) when directory changing is enabled. To solve that problem, the new sub-switch "/CS" enables a new key: the <SPACE> bar. When hit, the <SPACE> bar selects a directory, rather than changing to it, while <RETURN> continues to perform the change. When applied to a file entry then <SPACE> acts just like <RETURN>. Please note that <SPACE> is only available after activation by "/CS". As it is a sub-switch of "/C" it can only be activated in directory change mode, but in other modes it won't be useful anyway.

Have a look at these lines:

@echo off
set FROMFILE=NUL
set SELECT_TOP=Select the source file please . . .
select /C /Efromfile /OP C:
if %FROMFILE%==NUL goto end
set SELECT_TOP=Select the destination directory please . . .
select /AD /CS /Etofile /OP D:
echo copy %fromfile% %tofile%
:end
set SELECT_TOP=
set FROMFILE=
set TOFILE=

You might perhaps want to try this example, modify it or incorporate it into your own batch files.


Report •

#36
September 4, 2010 at 03:13:04
good job, guy!

well, I'm satisfied with this work, I think I'll not post anymore in this thread, but time to time I'll look down on your site to see updates to Select, also if I need then I will use the other tools in DOSUTILS.
If I found bugs then I'll let you know, I think I will use your e-mail address, because I think we have enough abusing this forum to do something which could not be allowed.

thank you for all!
see you!


Report •

#37
September 4, 2010 at 13:50:04
are you sure you uploaded select v1.5 ? 1.4 has CRC:95950AD9 just like 1.5.

Report •

#38
September 5, 2010 at 13:41:31
Ooops . . . i can't easily verify that right now on my LINUX system i use to access the internet. All i can see for sure is, that the source code which is also included in the archive is actually version 1.5.

Try to unpack the archive, then enter SELECT /?

This should give you a help screen showing you not only the version number but also the new sub-switch /CS. If you see this, than you definitely have version 1.5.


Report •

#39
September 6, 2010 at 06:21:02
now is ok, I don't know why the last time I check it show me 1.4...
SELECT 1.5 by JĀrgen Hoffmann (2010) j_ho..@...
ok =) ready to test it!

Report •

Ask Question