Skip to content

Technology Forum

SEO, Speed Up website, Server Optimization, Linux, Open Source Softwares

  • Home
  • General
    • Web Server
    • Website Formatting
  • IT Companies
  • Optimization
    • PHP
  • Linux
  • Home
  • Optimization
  • PHP
  • Using PHP script to delete a multiple files
Web Server
PHP FPM modification – Plesk
Servers
Different Types of Server for/on the Internet
Optimization
Add Trailing Slash to URL (.htaccess)
General
Overview of SSL Certificates
CSS
Word Wrap long text in HTML
Plesk Panel
Parallels Plesk for Linux services logs and configuration files

Using PHP script to delete a multiple files

Posted on September 16, 2012September 16, 2012 By admin No Comments on Using PHP script to delete a multiple files
PHP

This is short php script to delete files file by file in a loop. To do deletion with PHP, use this little PHP script:


$dir = "/directory/";
$dh = opendir($dir);
$i = 0;
while (($file = readdir($dh)) !== false) {
$file = "$dir/$file";
if (is_file( $file)) {
unlink( $file);
if (!(++$i % 100)) {
echo "$i files removedn";
}
}
}

This script helpful in deleting large files in a particular directory.

Tags: delete files delete files large directory delete large files in a directory large file listing

Post navigation

❮ Previous Post: Tools for Optimizing Images
Next Post: Overview of SSL Certificates ❯

You may also like

PHP
Apache Prefork versus Worker
MySQL
Calculate Query Cache
PHP
Encrypt and Decrypt for URL Using PHP
PHP
SSL Certificate

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

View Posts

  • PHP FPM modification – Plesk
  • HTML: Link rel – Preload
  • HTML: Attributes of rel
  • Linux Commands
  • Security HTTP Headers

Categories

  • Domain Name
  • General
    • Servers
    • Web Server
    • Website Formatting
  • IT Companies
  • Linux
  • MySQL
  • Optimization
    • PHP
  • Troubleshooting
  • Web Hosting Control Panel
    • Plesk Panel
  • Websites
    • CSS
    • HTML
    • Optimization
  • Windows
    • Windows 10

Recent Posts

  • PHP FPM modification – Plesk
  • HTML: Link rel – Preload
  • HTML: Attributes of rel
  • Linux Commands
  • Security HTTP Headers

Copyright © 2025 Technology Forum.

Theme: Oceanly News by ScriptsTown