Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Find and copy some files...

Posted on 1998-05-30
4
Medium Priority
?
170 Views
Last Modified: 2010-04-06
Help!
I want to find all the TXT-files (*.txt) in my TEMP-directory (c:\temp) and then copy them into another directory.
How can I fix that job? Please send me the source to do it...
Thanx!
SvR.
0
Comment
Question by:roosiedb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1349291
Don't remember exactly, but go to the Delphi pages and find a component that searches for files. Then give it parameters and copy the found files using the Delphi file routines...

http://sunsite.icm.edu.pl/delphi/ 
http://www.delphideli.com/ 
http://torry.rimini.com/ 

I'll try to find exactly...
0
 

Author Comment

by:roosiedb
ID: 1349292
I don't want to use any components, I want to have some code to copy (for example) all the *.txt -files in a directory. This must be possible with some (I hope) simple code...
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1349293
-Components come with sources. The copyfile procedure (or some other name) in Delphi is simple too. So just look at the source of the component to knwo how to find all files...
0
 
LVL 7

Accepted Solution

by:
ahalya earned 80 total points
ID: 1349294
you use  FindFirst, FindNext functions and "CopyFile" winapi.
( Matvey: not all components come with their source :-)

Here goes a sample proc.
//copies all files with name source.* to destn.* IF no EXT is given.
//otherwise copies source to destin.

procedure TMainForm.CopyMultipleFiles(source, destn:string);

var s1, s2 : string;
    Attr, Result : integer;
    SearchRec : TSearchRec;

begin;
if pos('.', source) = 0 then Source := Source + '.*';

Result := FindFirst(Source,  Attr, SearchRec);
While Result = 0 do
  begin
  s1 := ExtractFilePath(Source) + SearchRec.Name;
  s2 := ChangeFileExt(Destn, ExtractFileExt(SearchRec.Name));
  if not CopyFile(pchar(s1), pchar(s2), false) then
     begin;
     ShowMessage('Error Copying File: ' + S1);
     exit;
     end;
  Result := FindNext(SearchRec);
  end;
FindClose(SearchRec);
end;

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question