Warning re SHELL "DIR filespec > tempfile"
Posted: Thu Jan 19, 2006 8:40 pm
I was running a utility program that I wrote back in 1999. Under certain conditions the program needs to do:
SHELL "DIR filespec > tempfile"
Then it reads the tempfile and selects all the filenames only, not directory names, headings, etc.
Suddenly it's not working. After much scouting I discovered that a DIR under Windows XP produces a listing much different than the original DOS 6.22 that I was using at the time I wrote the program.
I don't know exactly when Windows changed to the new DIR format, but I did some testing and came up with a DIR command which will work for DOS 6.22 and Windows XP. The secret is using the /B switch which produces a "bare" listing of only the filenames (including the subdirectory names), and combining this with the /A-D which eliminates the subdirectory names, to get only the filenames. The new SHELL becomes:
SHELL "DIR filespec /B /A-D > tempfile"
A minor additional change in my program now picks up the filenames left-justified in each record of the tempfile.
So, if you've got an old program that does a DIR to get filenames, take another look at it if you're running a newer Windows.
*****
SHELL "DIR filespec > tempfile"
Then it reads the tempfile and selects all the filenames only, not directory names, headings, etc.
Suddenly it's not working. After much scouting I discovered that a DIR under Windows XP produces a listing much different than the original DOS 6.22 that I was using at the time I wrote the program.
I don't know exactly when Windows changed to the new DIR format, but I did some testing and came up with a DIR command which will work for DOS 6.22 and Windows XP. The secret is using the /B switch which produces a "bare" listing of only the filenames (including the subdirectory names), and combining this with the /A-D which eliminates the subdirectory names, to get only the filenames. The new SHELL becomes:
SHELL "DIR filespec /B /A-D > tempfile"
A minor additional change in my program now picks up the filenames left-justified in each record of the tempfile.
So, if you've got an old program that does a DIR to get filenames, take another look at it if you're running a newer Windows.
*****