It's better when it's simple

User Tools

Site Tools


Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community

Follow us on Facebook, Twitter and other social networks.


Removing Unused Files

When a new DokuWiki version is released, some of the files that were needed previously may become obsolete. Keeping these files is harmless usually but they might pose a security risk or break installations later, 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 systems the scripts below may delete too much!

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"
install/unused_files.txt · Last modified: 2018-05-05 16:35 by mforkel