===== 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 [[https://github.com/splitbrain/dokuwiki/raw/stable/data/deleted.files|https://github.com/splitbrain/dokuwiki/raw/stable/data/deleted.files]] :!: 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] == '#': continue line = line.rstrip(os.linesep) try: if os.path.exists(line): print('File removed => ' + line) os.remove(line) except OSError: pass 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): shutil.rmtree(path) print('Directory removed => ' + path) else: os.remove(path) print('File removed => ' + path) else: #print('File not found => ' + path) pass === Ruby Script === Here's a Ruby script doing the same files = File.read("./data/deleted.files").split("\n").grep(/^[^$#]/) files.each do |file| puts "Deleting #{file}." File.delete(file) rescue puts $! end === PHP Script === The same for PHP: '; } } 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"