Can I use double quotes in MS-DOS 6.22?

June 6, 2010 at 08:08:16
Specs: MS-DOS 6.22
Can I use double quotes in MS-DOS 6.22?

I created a batch-file, including DOS commands I point out:
IF EXIST "myfile.txt" echo The file exists!
IF "%myenv%"=="myfile.txt" ECHO env assigned!

On WIN98/DOS7.x everything works fine, but it does not work on DOS 6.22 !!
I have to remove the double quotes "" else --> IF not working properly.

Therefore, it is true that DOS6 not accept the double quotes?
how can I make sure that it works on 6.22 without removing the double-quotes from the batch-file?

I need to leave the double-quaotes because a file might have blank spaces!

as usual, thanks for the help

See More: Can I use double quotes in MS-DOS 6.22?

Report •

June 6, 2010 at 10:33:52
Dos 6.22 will shorten a Long File Name or one with spaces to 8.3 format so that's how your batch file must search for it. Check my posting here for details on LFN --> 8.3:

Anyway, I don't think 6.22 will recognize a file or folder name enclosed in quotes even if it's already in 8.3.

You're not really green until you're soylent green.

Report •

June 6, 2010 at 14:34:31
the problem is that I can NOT know if a file (given as %1 parameter to the batch) has a blank space or it is larger than 8.3 chars. Moreover, my batch file should be used in Windows 98 as well as MS-DOS 6.22.
So I ask if there is a way to use quotes in DOS 6.22. If so, then I can use the same batch in DOS6 and WIN98. Otherwise, I should use 2 batch files, one with quotes for DOS7 and WIN98, and one without quotes for DOS6.

Report •

June 6, 2010 at 16:17:28
I know of no way to use quotes in 6.22.

But note that 9X dos recognizes either LFN or the truncated LFN converted to 8.3. So a batch file that works for 6.22 should work for 9X also, but not vice versa.

So build one for 6.22 and assuming your variables include all the possiblities when the file or folder is converted, it will work for 9X.

You're not really green until you're soylent green.

Report •

Related Solutions

June 7, 2010 at 01:15:22
yep, you are right, but if I create a batch-file without quotes it work fine under DOS6 (and DOS7/WIN9x), but if I do something like this:
copy %myfile% %mydocs%
it does not work under win98 cause I've %mydocs% as:
C:\WINDOWS\Profiles\Turrican\My Documents
Under Windows NT/2000/XP/Vista/7 an issue like this can happen when I use %temp% since temp is:
C:\Documents and settings\Turrican\Local settings\Temp.

anyway, testing my batch-files I wll find the right solution that fit on win as well as dos.

thank you for the help.

Report •

June 7, 2010 at 02:23:18
Or do a VER and branch to a label.

Helping others achieve escape felicity


Report •

June 7, 2010 at 03:48:23
Actually you can use quotes in MS-DOS 6.22. Your original expression
>> IF "%myenv%"=="myfile.txt" ECHO env assigned! <<
is perfectly OK. In some rare cases like e.g. if you want to check for an empty string like this: >> If "%name%"=="" << you even have to use them.

So your problem is more likely caused by not properly distinguishing between the long and the short versions of the file name. Could you be more specific with respect to what actually doesn't work?

Report •

June 15, 2010 at 00:56:43
try with "IF EXIST <file>" instead of compare two string =)

IF EXIST "myfile.txt" echo The file exists!
it does not work on DOS 6.22, while on DOS 7.x or Win98 it's ok.

Report •

June 15, 2010 at 12:26:06
Yeah, I tried quotes on a 6.22 machine with some dos commands before posting above and anything within the quotes wasn't recognized as a legitimate file or folder name. If wiwa64 knows how to do it we would appreciate specific examples.

You're not really green until you're soylent green.

Report •

June 19, 2010 at 15:13:42
Unfortunately you are still very unspecific as to what actually doesn't work. In your original posting you just wrote >>I have to remove the double quotes "" else --> IF not working properly<<. However in your example, there are two lines with an "IF" statement and double quotes. So, whicht one did you mean?

My previous response refers to the second line, the >>If "%myenv%"=="myfile.txt" ECHO ...<<.

In the meantime i tried to "re-enact" your example and found out, that there is indeed a difference in the treatment of double quotes between DOS 6.22 and DOS 7.1 (aka Windows 98) which only refers to the IF EXIST statment, but not to the IF "string1"=="string2" construct.

DOS 6.22 takes the double quotes literally, hence it looks for a file which actually has these characters as part of its name. Of course such a file does not exist. DOS 7.1 silently ignores the quotes, which are only necessary if the filename contains blanks, which in turn don't exist in DOS 6.22 anyway.

Knowing this, you have several choices:
1. Use the form without quotes. In this case the code will work equally well under DOS 6.22 and DOS 7.1 but it will fail if the name contains blanks.
2. Use the form with quotes. Then it will properly process all filenames (with and without blanks) but only under DOS 7.1.
3. Try the following:

IF "%FILEFLAG%"=="TRUE" ECHO The file exists

The first line initially clears the environment variable FILEFLAG (you can choose any name you like)

The second line will set this variable to the value TRUE if the file exists but it will fail the name contains a blank.

The third line will set the variable if the file exists, no matter whether the names contains a blank or not but it will fail under DOS 6.22.

The fourth line will test whether any of the previous two other tests succeeded but the variable will remain empty if both tests failed meaning that the file really doesn't exist.

Report •

June 20, 2010 at 02:07:20
Thank you for your explanation =)
It's a good idea, I'll try to implement it as your example.

Report •

Ask Question