Board index » delphi » directory file list

directory file list

Hi,
I'd like to append a list of files sorted on name or extention. My
first idea was to do a <dos> dir /OE > file.lst , stripping the header
manualy and read from this to append.

As you can suspect I'm not an advanced programmer. But I'm shure there
must be an easier way to do this.

so How do I get a file list of a directory in TP

From the help I discovered FileList from a TFileList, it has something
to do with a dialog box item. I gess not really something I can use.

Thanks in advance
Chris

 

Re:directory file list


In article <342fe6d0.13048...@news.xs4all.be>, p...@xs4all.be says...

Quote

>Hi,
>I'd like to append a list of files sorted on name or extention. My
>first idea was to do a <dos> dir /OE > file.lst , stripping the header
>manualy and read from this to append.

>As you can suspect I'm not an advanced programmer. But I'm shure there
>must be an easier way to do this.

>so How do I get a file list of a directory in TP

>From the help I discovered FileList from a TFileList, it has something
>to do with a dialog box item. I gess not really something I can use.

>Thanks in advance
>Chris

TP7/BP7 has a DIRDEMO.PAS in the examples. You have to modify a bit, but
it has a powerful quicksort, too! I think you have to strip the header and
summary printing lines, replace the command line var with a constant value,
then it will work!

BandiT
alias Papai Andras

Re:directory file list


Well, if you don't want to take the time to write a program,
in DOS you can make a batch file like:
dir /b /oe > listq123.tmp  ; the /b option strips the header
copy %1+listq123.tmp %1
del listq123.tmp

Quote
Christine Hollanders wrote:

> Hi,
> I'd like to append a list of files sorted on name or extention. My
> first idea was to do a <dos> dir /OE > file.lst , stripping the header
> manualy and read from this to append.

> As you can suspect I'm not an advanced programmer. But I'm shure there
> must be an easier way to do this.

> so How do I get a file list of a directory in TP

> From the help I discovered FileList from a TFileList, it has something
> to do with a dialog box item. I gess not really something I can use.

> Thanks in advance
> Chris

Re:directory file list


On Mon, 06 Oct 1997 16:02:42 -0400, Jared Showalter

Quote
<shonwald.REMOVET...@gate.net> wrote:
>Well, if you don't want to take the time to write a program,
>in DOS you can make a batch file like:
>dir /b /oe > listq123.tmp  ; the /b option strips the header
>copy %1+listq123.tmp %1
>del listq123.tmp

You can even shorten this to one line:
 dir /b /oe >>%1

Quote
>Christine Hollanders wrote:

>> Hi,
>> I'd like to append a list of files sorted on name or extention. My
>> first idea was to do a <dos> dir /OE > file.lst , stripping the header
>> manualy and read from this to append.

--
J.R. Ferguson, Amsterdam, The Netherlands
e-mail: j.r.fergu...@iname.com

Re:directory file list


On Sun, 28 Sep 1997 23:22:58 GMT, p...@xs4all.be (Christine

Quote
Hollanders) wrote:
>Hi,
>I'd like to append a list of files sorted on name or extention. My
>first idea was to do a <dos> dir /OE > file.lst , stripping the header
>manualy and read from this to append.

>As you can suspect I'm not an advanced programmer. But I'm shure there
>must be an easier way to do this.

>so How do I get a file list of a directory in TP

>From the help I discovered FileList from a TFileList, it has something
>to do with a dialog box item. I gess not really something I can use.

>Thanks in advance
>Chris

I'd go the DOS route if I were you, but if you really want to program
the operation, start looking at FindFirst and FindNext in the docs.

Tom

--
http://www.arunet.co.uk/tkboyd/prgmr1.htm
Ideas, links, for programmers of IBM-type pcs. Pascal, Delphi, etc

Re:directory file list


Quote
> >Hi,
> >I'd like to append a list of files sorted on name or extention. My
> >first idea was to do a <dos> dir /OE > file.lst , stripping the
> >header manualy and read from this to append.

> >As you can suspect I'm not an advanced programmer. But I'm shure
> >there must be an easier way to do this.

/b helps: dir /oe /b > file.lst
Gets rid of the header. Also (in DOS 6.2) changes the filename from
"filename    ext"  to  "filename.ext"

Quote
> >so How do I get a file list of a directory in TP
> >...

> >Thanks in advance
> >Chris

> I'd go the DOS route if I were you, but if you really want to program
> the operation, start looking at FindFirst and FindNext in the docs.

> Tom

Start looking for FindFirst in the on-line help in the DOS IDE rather
than the printed docs - there's a demo program you can
cut/paste/compile. It looks for '*.PAS' but you can change that easily.
One thing that is not obvious is the attribute: looking up ARCHIVE in
the on-line help gives you a list but doesn't tell you that: if the
attribute is 0, FindFirst/FindNext will only find ordinary files, if
it's VolumeId then only Volume labels are found (if there are any!), if
it's any combination of Hidden, SysFile, Directory then those files
_and_ normal files will be found. Also you combine them with OR, e.g.
FindFirst('*.*',Archive or hidden,DirInfo). How you sort the names
depends on how you want to store them, one possibility might be
tSortedCollection.

Frank

Other Threads