Created
October 1, 2014 10:09
-
-
Save random-robbie/7f4d32703f75c3cf65e0 to your computer and use it in GitHub Desktop.
PHP - Remove 0kb files from folder and put text file with removed file's in.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fol = "/var/www/zerobytes/test/"; | |
if ($handle = opendir($fol)) { | |
while (false !== ($entry = readdir($handle))) { | |
if ($entry != "." && $entry != ".." && $entry != "removed.txt" && $entry != is_dir("".$fol."".$entry."")) { | |
//Check filesize | |
if(filesize("".$fol."".$entry."") < '1000'){ | |
$myfile = fopen("".$fol."removed.txt", "a") or die("Unable to open file!"); | |
$txt = "$entry\r\n"; | |
fwrite($myfile, $txt); | |
fclose($myfile); | |
echo "".$entry." - Removed <br>"; | |
unlink ("".$fol."".$entry.""); | |
} | |
} | |
} | |
closedir($handle); | |
} | |
echo "If no files are listed above then the files are bigger than 0kb"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment