Getting DIR stuff
- {Nathan}
- Veteran
- Posts: 1169
- Joined: Thu Aug 19, 2004 6:08 pm
- Location: The wetlands of central Ohio, USA
- Contact:
Getting DIR stuff
I am interested in making some utilities for DOS on my old laptop, but I am stuck in a delima. How can I get the contents of a directory, just the files, in a list, with the DIRS seperate? I want to keep my code as clean as possible with this... and I know that some DIR command parameter will do this, but there is no way to seperate the directory(s) from the files.
-
- Veteran
- Posts: 703
- Joined: Sun Nov 14, 2004 7:36 am
- Contact:
If you're using VBDOS or PDS (I believe) the dir$ has a parameter that that specifies the type of file you're looking for...I believe that doing something like:
DIR$("FileParameters", 16) will only return folders
DIR$("FileParameters", 16) will only return folders
When God created light, so too was born, the first Shadow!
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
-
- Veteran
- Posts: 703
- Joined: Sun Nov 14, 2004 7:36 am
- Contact:
NOt much you can do I think from QB itself...maybe you can SHELL the DOS operations to a file and process that file accordingly.....
When God created light, so too was born, the first Shadow!
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
MystikShadows
Need hosting? http://www.jc-hosting.net
Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Try these SHELL statements from your program.
To get a list of all the filenames only:
SHELL "DIR /A-D /B >MYFILES.TXT"
To get a list of all the sub-directories (one level) only:
SHELL "DIR /AD /B >MYDIRS.TXT"
The above assumes that your program is positioned at the directory that you want to see the files and dirs.
If not, and FULLPATH$ contains the path\directory in question, then:
To get a list of all the filenames only:
SHELL "DIR "+FULLPATH$+" /A-D /B >MYFILES.TXT"
To get a list of all the sub-directories (one level) only:
SHELL "DIR "+FULLPATH$+" /AD /B >MYDIRS.TXT"
*****
To get a list of all the filenames only:
SHELL "DIR /A-D /B >MYFILES.TXT"
To get a list of all the sub-directories (one level) only:
SHELL "DIR /AD /B >MYDIRS.TXT"
The above assumes that your program is positioned at the directory that you want to see the files and dirs.
If not, and FULLPATH$ contains the path\directory in question, then:
To get a list of all the filenames only:
SHELL "DIR "+FULLPATH$+" /A-D /B >MYFILES.TXT"
To get a list of all the sub-directories (one level) only:
SHELL "DIR "+FULLPATH$+" /AD /B >MYDIRS.TXT"
*****
If you are ahead of me, lead.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
If you are behind me, follow.
If you are not doing anything,
Get out of the way.
QB71 or FB for DOS
Both have the DIR$() command:
You may have to remove the () on the last DIR$
Both have the DIR$() command:
Code: Select all
t$ = DIR$("*.*")
do while t$ <> ""
print t$
t$ = DIR$()
loop
I have left this dump.
You can also make use of so called batch-files.
Same I have at mine. I use linux-command because they're
somewhat easier.
You could make for dir ls.bat
I hope this helps a bit.
grtz
Seb
Same I have at mine. I use linux-command because they're
somewhat easier.
You could make for dir ls.bat
Code: Select all
ls.bat
@echo off
if %1 == "-l" goto lsl
if %1 == "-a" goto lsa
if %1 == "-R" goto lsR
if %1 == "--help" then goto lshelp
dir %2 /b /l /p
goto end
:lsl
dir %2 /Ogn /p
goto end
:lsa
dir %2 /a /p
goto end
:lsR
dir %2 /s /p
goto end
:lshelp
echo LS v.0.0.1
echo.
echo Syntax: LS [-command]
echo -a : show all files including hidden files
echo -l : show long list
echo -R : show all files in directory and subdirectories
echo.
:end
grtz
Seb