Topic: How to delete files matching pattern within a directory

Do you have an example to  delete files matching pattern within only one directory. If possible the matching pattern exist in other directory like
d:\folder' & d:\folder\Test. But I want delete only in directory folder.

pattern like *.PDF

Regards,

Pierre Perreault, Canada

MVD is a great developement system !!!!

Re: How to delete files matching pattern within a directory

I'm not sure that I understand your question completely, but  check out this example. You can find files then delete them.
http://myvisualdatabase.com/forum/viewt … ?pid=25249

Dmitry.

Re: How to delete files matching pattern within a directory

спасибо Dimitry,

Take that example

In folder c:\Test\, I have many PDF files.

& in the folder c:\Test\Nivel2\, I have others PDF files.

I want to delete ONLY in directory c:\Test\, *.PDF files    BUT NO in other subdirectory like  c:\Test\Nivel2\ *.PDF

I want to deleted All when I press on button (automaticly)

Regards,

Pierre P

Re: How to delete files matching pattern within a directory

Please download latest beta version
https://www.dropbox.com/s/wutj7mnux7f3a … a.zip?dl=0


Example:

procedure Form1_Button4_OnClick (Sender: TObject; var Cancel: boolean);
var
    sl: TStringList;
    i, c: integer;
begin
    sl := TStringList.Create;

    sl.Text := GetFilesList('c:\Test\', '*.pdf', False);
    c := sl.Count-1;
    for i := 0 to c do DeleteFile(sl[i]);

    sl.Free;
end;
Dmitry.

Re: How to delete files matching pattern within a directory

спасибо Dimitry,

Perfect job,


When version 4.6 will be release

Regards,

Pierre P
Canada

Re: How to delete files matching pattern within a directory

Soon  )

Dmitry.