xbmc logoI’m a big fan of XBMC KODI but have an issue when it comes to the way KODI handles removing watched movies.  When  you delete a movie from the database (and file system if you’ve configured KODI to allow file deletion) KODI deletes the movie file but not the directory, thumbnails, and various other accompanying files.  After a while you have all these orphaned movie folders lying around.

Here’s a thread on the subject: //forum.xbmc.org/showthread.php?tid=128963

Hopefully the folks at KODI will ad a configuration switch that will tell KODI to delete the media file and its accompanying directory some day.  In the mean time I’ve come up with a DOS batch file that can be run manually to remove orphaned directories.

My requirements:

  1. check only the first level of directories off my movie folder.  (To enable the batch file to look into all sub-folders just add a “/r” after “for” in the batch file.)
  2. Ignore folders that contain at least one example of  the various movie files ex avi, iso, mkv.
  3. Ignore “movie sets“. Movies that are sequels or are apart of a directly related movie series. To facilitate this I add the file “folder.ignore” to the top directory of a “movie set.”
  4. Prompt me to delete the orphaned folders.

How to use:

  1. Create a text file with the .cmd extension in your movie folder directory ex “foldercheck.cmd”
  2. Copy the code below into your newly created file.
  3. Create a text file called “folder.ignore” in any folders you don’t want the batch file to check.
  4. Double click your newly created foldercheck.cmd file to launch the clean up script.
@rem ------start of code [updated Saturday, June 29 12:35]
@echo Scanning for orphaned directories...
@echo off
for /d %%f in (*) do (
if not exist %%f*.mkv (
 if not exist %%f*.avi (
  if not exist %%f*.iso (
   if not exist %%f*.ifo (
    if not exist %%f*.mp4 (
     if not exist %%f*.m4v (
      if not exist %%f*.img (
       if not exist %%f*.divx (
        if not exist %%f*.ignore (

@echo Delete the following folder?:
rmdir /S "%%f"

@rem ----- end of code
Disclaimer: I accept no liability for any damages, including, but limited to, direct, indirect, special, or consequential damages arising out of, resulting from, or any way connected to the use of the batch file listed above. In other words if you delete the shit outta your movie collection because you don’t understand how to use/configure a dos batch file don’t come crying to me.