title: Copy everything from a source directory to a new directory Delphi EX7
body: <p>My end goal is to copy all the relevant files from one folder to another. So e.g. we have <code>C:\Users\Tool\Desktop\test\oldStuff</code>. In the folder <code>oldStuff</code> we have more folders as well as some <em>mp3</em>,<em>mp4</em> and <em>txt</em> files.</p>
  
  <p>Now what I would like to do is copy all the <em>mp4</em> files that are smaller than a GB to <code>C:\Users\Tool\Desktop\test\New_Stuff_Less_than_a_Gig</code>, and the <em>.mp4</em> files that are bigger than a GB to <code>C:\Users\Tool\Desktop\test\New_STuff_Bigger_than_a_Gig</code>.</p>
  
  <p>I though is this would be pretty easy but I was wrong. So far have this, didn't worry about file type for now so just made it <code>*.*</code>  </p>
  
  <pre><code> procedure TForm4.Button1Click(Sender: TObject);
   var
     f: TSearchRec;
     Dir: string;
   begin
      if not SelectDirectory(Dir,widestring(Dir),Dir) then   Exit;
      FileMode:=0;
      if FindFirst(Dir+'\*.*',faAnyFile,f) = 0 then
      repeat
           try
            if (f.Attr and faDirectory ) &lt; $00000008 then
            CopyFile(PChar(Dir+'\'+f.Name),PChar
   ('C:\Users\Tool\Desktop\test\new\'+f.Name),false);
           except
            on e: exception do
              ShowMessage(E.Message);
           end;
      until findNext(f) &lt;&gt; 0
   end;
  </code></pre>
  
  <p>which will copy anything in the folder that is selected but it doesn't copy anything from the folders within the selected folder. E.g. if we have <code>C:\Users\Tool\Desktop\test\oldStuff\movie.mp4</code> it will copy the <code>Movie.mp4</code> file but if we have <code>C:\Users\Tool\Desktop\test\oldStuff\movies\Movie.mp4</code> it won't copy the <code>Movie.mp4</code> file. I though I could just do something like this </p>
  
  <pre><code>CopyFile.size &lt; 1000 (PChar('C:\Users\Tool\Desktop\test\oldStuff\*.*'+f.Name),
                     PChar('C:\Users\Tool\Desktop\test\new_Stuff\'+f.Name),false)
  </code></pre>
  
  <p>or even just </p>
  
  <pre><code>CopyFile (PChar('C:\Users\Tool\Desktop\test\old\*.*'+f.Name),
                     PChar('C:\Users\Tool\Desktop\test\new\'+f.Name),false);
  </code></pre>
  
  <p>but it didn't copy anything.</p>