Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,818 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,093 people online right now. Registration is fast and FREE... Join Now!




loop through all files in a directory

 
Reply to this topicStart new topic

loop through all files in a directory

kmoloney
22 Aug, 2008 - 06:35 AM
Post #1

New D.I.C Head
*

Joined: 21 Aug, 2008
Posts: 2

i wish to loop through all files in a directory and copy all files of a given extension using PASCAL.

CODE

COPYLOCATION   := 'C:\Documents and Settings\kmoloney\Desktop\Silver\';    

For k := 0 To COPYLOCATION.FileCount - 1 Do
        Begin

            Document := COPYLOCATION.DM_LogicalDocuments(k);

                     //copy files to desired location
                 copyfile(document.DM_FullPath, REPORTLOCATION + document.DM_FileName, true);


               //add all copied files to report
            ReportFile.Add(Document.DM_FullPath);

        End;


COPYLOCATION is the directory where the files i want to loop through are.
in my loop, obviously ".filecount" is wrong...... i was wondering if someone knew how to loop through all the files?
then i will use an if statement to only get the files with the extension i want.
and then ill just use the copyfile method as above.

please help!
how do i loop through the files in a directory??
User is offlineProfile CardPM
+Quote Post

kapax
RE: Loop Through All Files In A Directory
23 Aug, 2008 - 06:16 AM
Post #2

New D.I.C Head
*

Joined: 2 Jul, 2008
Posts: 39



Thanked: 1 times
My Contributions
I wrote a stupid thing, so I deleted my post blush.gif

This post has been edited by kapax: 23 Aug, 2008 - 06:19 AM
User is offlineProfile CardPM
+Quote Post

coaster3000
RE: Loop Through All Files In A Directory
28 Aug, 2008 - 03:26 PM
Post #3

D.I.C Head
**

Joined: 28 Aug, 2008
Posts: 79


My Contributions
QUOTE(kmoloney @ 22 Aug, 2008 - 07:35 AM) *

i wish to loop through all files in a directory and copy all files of a given extension using PASCAL.

CODE

COPYLOCATION   := 'C:\Documents and Settings\kmoloney\Desktop\Silver\';    

For k := 0 To COPYLOCATION.FileCount - 1 Do
        Begin

            Document := COPYLOCATION.DM_LogicalDocuments(k);

                     //copy files to desired location
                 copyfile(document.DM_FullPath, REPORTLOCATION + document.DM_FileName, true);


               //add all copied files to report
            ReportFile.Add(Document.DM_FullPath);

        End;


COPYLOCATION is the directory where the files i want to loop through are.
in my loop, obviously ".filecount" is wrong...... i was wondering if someone knew how to loop through all the files?
then i will use an if statement to only get the files with the extension i want.
and then ill just use the copyfile method as above.

please help!
how do i loop through the files in a directory??

umm i might be able to do that with batch even though i am not experienced not even for 1 year in programming but i got all the basics i just do a little research and i can build a batch file code for you if you will except a batch file or exe because i have a compiler too

EDIT wait actually i really do not know if i can do it i just read the rest of this post and i am not quite sure about it so i am sorry...
if only i could delete this post (because i do not like wasting data on websites so i just delete my posts if it was useless)

This post has been edited by coaster3000: 28 Aug, 2008 - 03:28 PM
User is offlineProfile CardPM
+Quote Post

DeCompile
RE: Loop Through All Files In A Directory
28 Aug, 2008 - 05:30 PM
Post #4

D.I.C Head
**

Joined: 20 Jul, 2008
Posts: 180



Thanked: 6 times
My Contributions
Why would you want to loop through all the files in the directory?

This could simply be accomplished through a batch file.

ie. COPY *.DOC c:\documents\


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 02:58PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month