It's better when it's simple

User Tools

Site Tools


Removing Unused Files

When a new DokuWiki version is released, some of the files that were needed previously may become obsolete.

Keeping the files may cause the following issues:

  • Misleading error messages related to outdated plugins.
  • They pose a security risk.
  • They could break later installations.

So we recommend to delete them.

A list of all files that were removed in recent releases can be found in data/deleted.files. You should check if they still exist in your install. If they do, delete them.

You can also see the current list at

:!: Important: The list of files is case-sensitive. On case-insensitive file systems1) the scripts below may delete too much!

Using a Plugin

When upgrading your wiki using the upgrade Plugin, the plugin will take care of removing the deleted files automatically for you.

Alternatively the removeold Plugin can be used.

Using a Script

People with shell access to their server can use a script to automatically delete all old files.

Linux Shell

This simple line should work on any Linux system

grep -Ev '^($|#)' data/deleted.files | xargs -n 1 rm -vf

*nix Shell

Some systems may not support the “rm -d” option for directory removal. In that case, you have to use recursive removal (just be sure to double-check that the file list does not include any paths that will delete too much):

grep -Ev '^($|#)' data/deleted.files | xargs -n 1 rm -fr

Python Script

Here's a Python script that will also print the files deleted

import os
for line in open("./data/deleted.files"):
    if line.isspace() or line[0] == '#':
    line = line.rstrip(os.linesep)
        if os.path.exists(line):
            print('File removed =>  ' + line)
    except OSError:

Here's an alternative Python script that is case sensitive and will also delete directories included in the list

import os
import shutil
def exists_casesensitive(path):
    if not os.path.exists(path):
        return False
    directory, filename = os.path.split(path)
    return filename in os.listdir(directory)
with open("./data/deleted.files") as file:
    for line in file:
        line = line.strip()
        if line and not line.startswith('#'):
            path = line.rstrip(os.linesep)
            if exists_casesensitive(path):
                if os.path.isdir(path):
                    print('Directory removed =>  ' + path)
                    print('File removed =>  ' + path)
                #print('File not found => ' + path)

Ruby Script

Here's a Ruby script doing the same

files ="./data/deleted.files").split("\n").grep(/^[^$#]/)
files.each do |file|
  puts "Deleting #{file}."
  File.delete(file) rescue puts $!

PHP Script

The same for PHP:

/* Security function, comment this out to "activate" the script. */
exit('Check source');
$path = getcwd();
if(file_exists($path . '/data/deleted.files')) {
  $file = fopen($path . '/data/deleted.files', 'r');
  while(false !== ($line = fgets($file))) {
    $line = trim($line);
    if(!empty($line) && !preg_match('/^\#/', $line) && file_exists($path . '/' . $line)) {
      unlink($path . '/' . $line);
      echo '/' . $line . ' - deleted<br/>';
  echo 'Done!';

Powershell Script

Here's a one-line powershell script doing the same

Get-Content .\data\deleted.files | Where-Object {$_ -notmatch '^($|#)' -and (Test-Path $_ )} | Foreach-Object {Remove-Item -path $_ -Force -Recurse}

CMD Script

Here's a one-line Windows's CMD script doing the same, although you may need to first reverse all the slashes in 'deleted.files' for the filenames to be accepted.

for /F %i in ('findstr /R /V /C:"^#" /C:"^$" data\deleted.files') do del "%i"
Case-insensitive file systems are, under some circumstances: Windows and macOS
install/unused_files.txt · Last modified: 2023-02-28 13:41 by saggi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki