Ui Delphi ist doch komplizierter als ich nach den Anfängertutorials erwartet habe.
Der Code bisher sieht so aus:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; ListBox1: TListBox; procedure Button1Click(Sender: TObject); procedure ListBox1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure GetFilesInDirectory(Directory: String; const Mask: String; List: TStrings; WithSubDirs, ClearList: Boolean);
procedure ScanDir(const Directory: String); var SR: TSearchRec; begin if FindFirst(Directory + Mask, faAnyFile and not faDirectory, SR) = 0 then try repeat List.Add(Directory + SR.Name) until FindNext(SR) <> 0; finally FindClose(SR); end;
if WithSubDirs then begin if FindFirst(Directory + '*.*', faAnyFile, SR) = 0 then try repeat if ((SR.attr and faDirectory) = faDirectory) and (SR.Name <> '.') and (SR.Name <> '..') then ScanDir(Directory + SR.Name + '\'); until FindNext(SR) <> 0; finally FindClose(SR); end; end; end;
begin List.BeginUpdate; try if ClearList then List.Clear; if Directory = '' then Exit; if Directory[Length(Directory)] <> '\' then Directory := Directory + '\'; ScanDir(Directory); finally List.EndUpdate; end; end;
procedure TForm1.Button1Click(Sender: TObject); begin GetFilesInDirectory('C:\Downloads\Trance', '*.mp3*', Listbox1.Items, False, True); end;
procedure TForm1.ListBox1Click(Sender: TObject); begin
end;
end. |
Nur werden da die Gefundenen Ergebnisse überhaupt in einem String gespeichert ?
Zur Methode mit dem umbenennen hab ich folgendes gefunden:
www.dsdt.info/tipps/?id=128
Nur dazu bräuchte ich dann die gefundenen Datei ja auch wieder in einem neuen Strink oder nicht ? Und auch wenn dann alle Datein in nem string sind, kann ich die dann mit der Funktion überhaupt so umbenennen lassen das nur die ersten 3 zeichen verschwinden ?
Moderiert von
Gausi: Quote- durch Delphi-Tags ersetzt