Board index » delphi » Directory Contents

Directory Contents

I'm trying to write a program that will take the names of all of the files
in a certain directory, and rename them given certain crieria.  Basically,
the Rename procedure will rename the files, but how can I get the directory
contents into an array of some sort?  Once I know the filenames, can I even
rename to a long filename in DOS Turbo?  Thanks.
 

Re:Directory Contents


Quote
"aardvark" <thegeneralst...@softhome.net> wrote in message

news:LfCp6.355851$f36.12283300@news20.bellglobal.com...

Quote
> I'm trying to write a program that will take the names of all of the files
> in a certain directory, and rename them given certain crieria.  Basically,
> the Rename procedure will rename the files, but how can I get the
directory
> contents into an array of some sort?  Once I know the filenames, can I
even
> rename to a long filename in DOS Turbo?  Thanks.

Use the FindFirst/FindNext procedures, and specify a suitable wild card
as a file name, e.g. *.*.

Klaus

Re:Directory Contents


JRS:  In article <LfCp6.355851$f36.12283...@news20.bellglobal.com>, seen
in news:comp.lang.pascal.borland, aardvark
<thegeneralst...@softhome.net> wrote at Thu, 8 Mar 2001 02:37:31 :-

Quote
>I'm trying to write a program that will take the names of all of the files
>in a certain directory, and rename them given certain crieria.  Basically,
>the Rename procedure will rename the files, but how can I get the directory
>contents into an array of some sort?  Once I know the filenames, can I even
>rename to a long filename in DOS Turbo?  Thanks.

Don't use an array; AIUI, the possible number of files in a directory
exceeds what can be conveniently stored in an array.  Use
FindFirst/FindNext, as in, for example, listdirs.pas, mv.pas, hunt.pas,
slow.pas, all via sig line 2, and in the BP7 on-line Help.

For long file names, read the mini-FAQ, posted here weekly when the
software remembers.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:Directory Contents


Quote
In article <pAd2MhM4R6p6E...@merlyn.demon.co.uk>, Dr John Stockton wrote:
>JRS:  In article <LfCp6.355851$f36.12283...@news20.bellglobal.com>, seen
>in news:comp.lang.pascal.borland, aardvark
><thegeneralst...@softhome.net> wrote at Thu, 8 Mar 2001 02:37:31 :-
>>I'm trying to write a program that will take the names of all of the files
>>in a certain directory, and rename them given certain crieria.  Basically,
>>the Rename procedure will rename the files, but how can I get the directory
>>contents into an array of some sort?  Once I know the filenames, can I even
>>rename to a long filename in DOS Turbo?  Thanks.

>Don't use an array; AIUI, the possible number of files in a directory
>exceeds what can be conveniently stored in an array.  Use
>FindFirst/FindNext, as in, for example, listdirs.pas, mv.pas, hunt.pas,
>slow.pas, all via sig line 2, and in the BP7 on-line Help.

Renaming files within a findfirst/findnext/(Findclose) loop isn't safe
afaik?

Re:Directory Contents


JRS:  In article <slrn9ag2kt.1vjl.mar...@toad.stack.nl>, seen in
news:comp.lang.pascal.borland, Marco van de Voort <mar...@toad.stack.nl>
wrote at Thu, 8 Mar 2001 22:41:33 :-

Quote
>In article <pAd2MhM4R6p6E...@merlyn.demon.co.uk>, Dr John Stockton wrote:
>>JRS:  In article <LfCp6.355851$f36.12283...@news20.bellglobal.com>, seen
>>in news:comp.lang.pascal.borland, aardvark
>><thegeneralst...@softhome.net> wrote at Thu, 8 Mar 2001 02:37:31 :-
>>>I'm trying to write a program that will take the names of all of the files
>>>in a certain directory, and rename them given certain crieria.  Basically,
>>>the Rename procedure will rename the files, but how can I get the directory
>>>contents into an array of some sort?  Once I know the filenames, can I even
>>>rename to a long filename in DOS Turbo?  Thanks.

>>Don't use an array; AIUI, the possible number of files in a directory
>>exceeds what can be conveniently stored in an array.  Use
>>FindFirst/FindNext, as in, for example, listdirs.pas, mv.pas, hunt.pas,
>>slow.pas, all via sig line 2, and in the BP7 on-line Help.

>Renaming files within a findfirst/findnext/(Findclose) loop isn't safe
>afaik?

I've not found it to be unsafe, and don't see why it should be.  The
Finds iterate through an array of 32-byte records, one at a time,
skipping disused ones.

The related problem is when a file is created or *apparently* changed.

A new-created file will use a vacant record, which may happen to be
either before or after the current record.

If a file is edited by any normal editor (as opposed to a "patcher"),
then a new copy will be created and the existing one either deleted or
renamed as backup, and the existing backup ... .  This has logical
consequences, and the apparently-same file may or may not be found
again.

However, the situation could be different in an OS where file entries
were held on a linked list, with removals being closed up; though even
there a rename should be harmless, since it is just a directory field
replacement.

H'mmm - a rename to a different directory is in effect a deletion within
the present directory, but that does not have harmful consequences.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:Directory Contents


Re:Directory Contents


does anyone know where i can download
borland pascal for free.?
thanks

aardvark <thegeneralst...@softhome.net> schreef in berichtnieuws
LfCp6.355851$f36.12283...@news20.bellglobal.com...

Quote
> I'm trying to write a program that will take the names of all of the files
> in a certain directory, and rename them given certain crieria.  Basically,
> the Rename procedure will rename the files, but how can I get the
directory
> contents into an array of some sort?  Once I know the filenames, can I
even
> rename to a long filename in DOS Turbo?  Thanks.

Re:Directory Contents


In article <jeObB0PqAHA....@asd24-aux-005.raketnet.nl>, evandor
<evan...@raketnet.nl> writes

Quote
>does anyone know where i can download
>borland pascal for free.?
>thanks

You can get Pascal 5.5 from the Borland Museum web site, you need to
register.

It has all you need for learning Pascal but obviously NOT all the
features of the later Ver's

Jim Barr  http://www.wandana.demon.co.uk

Barrs Law of Recursive futility
        If you're smart enough to use one of these....
                .....you can probably manage without one!

Other Threads