Deleting empty (0-lenght) files in a directory
<p>the php script below select and elaborate one by one all .txt files contained in a specific directory. First of all, a file is copied in a subdirectory named "copy", after the script calls read.php so that the file is analyzed and elaborated. Finally the same file can be deleted from the main directory.
This is done to all files in the folder, until they end.</p>

<p>THE ISSUE: unfortunately the script stops when a 0 KB file (empty) is found. Probabily the problem is read.php but i can't modify this. So I'd like to delete automatically these unwanted empty files so that the process go on regularly.</p>

<p>Any suggestion? TNX</p>

<pre><code> &lt;?php
 $files = glob( '*.txt' );
 array_multisort(
    array_map( 'filemtime', $files ),
    SORT_NUMERIC,
    SORT_ASC,
    $files
 );

 $filename="$files[0]";
 foreach($files as $filename) {

    copy($filename,"./copy/$filename"); 
    echo "&lt;b&gt; $filename &lt;/b&gt;File copied&lt;br&gt;";   

    include ("read.php");

    sleep(4);

    unlink($filename);
    echo "$filename elaborated and deleted from the main folder.&lt;br&gt;";  
 }
 ?&gt;
</code></pre>
