Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Files insdide a folder

Status
Not open for further replies.

THEMAN101

Programmer
Apr 29, 2003
44
US
Hey i posted here before about getting the files in a folder. All the results were very long pieces of code that seemed way to much for me. All i need is to get the files and hopefully subfolders in a directory. All i really need is there name but if for just a small piece of code i could get other attributes that would be good. FILES and sheel dir /o/p dont satisfy. They give me details about the machine and other stuff i dont want.

Please help

Thanks
 
For directories : SHELL "dir /ad > onefile.ext" (Not sure for the parameter,check it with dir /? in the DOS)
For files matching a$ (IE: a$="*.*")
SHELL "dir /a "+a$+" > onefile.ext"
Rename onefile.ext as you wish in the code.

Then use something like
[tt]
OPEN "onefile.ext" FOR INPUT AS #1 'If doesn't work,try OUTPUT !
list$=""
DO
LINE INPUT #1,tmp$
list$=list$+" | "tmp$
LOOP UNTIL EOF(1)
CLOSE #1
END

Directories/files list are now in list$ !

Reply on this forum if this works,I'll try to indicate you how to extract and count names(even if the DIM instruction is dreadful in my opinion!)
 
thanks alot.
shell /0/b/p worked.

this forum rocks.
 
As you probably have guessed, there's no built-in function to perform this task. So, you have to figure out a workaround. The examples above use the DIR command to give you a directory list with just filenames, no other info. This is the easiest way to do it. You then just parse the data with your QBasic program, which isn't too hard. You've gotta remember QBasic was pretty primitive back then, didn't have too many useful functions built into it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top