I wanted to “clean” all my folders from garbage but keep all my video files because (if you have one of situations hereafter, you can use this procedure to solve it) :
- i had many images in my folders downloaded there by a 3rd tool and no more used (i wanted to reset them all and redownload them automatically with kodi and other 3rd tool) ;
- i had some episodes multiple times with different sizes (i wanted to keep the best ones only) ;
- some episodes had been deleted but were still noted as downloaded in sonarr, mainly for unmonitored old shows (i wanted them to appear as missing) ;
- some episodes were corrupted and no more readable (i wanted them to be deleted and set as missing) ;
- during years, i used different renaming conventions and wanted the same everywhere ;
- some episodes were downloaded but marked as missing and vice-versa (i wanted to set them right).
I did it this way, works perfectly, no need for a script or programmation :
- in the settings of sonarr, disable the automatic scan of the factory folder (set 0 for the time) ;
- if you have corrupted video files and want to filter them, be sure to use the full mediainfo information in the new name of your episodes (see end of document for example) ;
- on my HDD’s, i have a single folder root “TVShows” containing all the subfolders for the shows : on the same drive, create a folder “dronefactoryHDD1” (f.e.) but outside your root folder (we use the same drive so that no extra space is needed and the moves of the files need no time) ;
- move all the video files from your root to this new folder : there are free tools to display folders and subfolders in a “flatten” way so you see all the files of a directory on 1 page, recursively : then select only the files of the right types (mkv, avi, mp4, wmv, …) and cut+paste them into the folder “dronefactory” created in the previous point ;
- delete completly your root folder, the one that contains all the subfolders (yes, yes), and keep only the root folder of the series (in my case, my “TVShows” folder, which is empty after the operation, no subfolders even) ;
- in sonarr, go to the series editor, select the circle in the top right corner, and sort the lines by path ;
- check the lines that were on the HDD and we deleted (you check the first one and then the last one while keeping the shift of the keyboard to select all the lines between the 2 checked) ;
- note the number of series you selected (appears below) ;
- note the name of the first and last series you checked ;
- set monitored=yes, profile=any (is a profile i made that keep all the videos - see end of document for description), let the 2 other combos on “no change” and click on the red button “organize” : sonarr recreates then all the subfolders on your HDD, with the right names and the subfolders for the seasons ;
- your lines should still be checked : click on the Save button now to apply the new options we selected ;
- don’t change anything in that page (the order must stay so) and click on “season pass” above ;
- do not change the order of this list either ! ;
- click on the circle in the top right corner if not selected ;
- find the first show in the list (the one you noted) and check it ;
- find the last show in the list and shift-check it ;
- verify that the number of selected shows is the same as the one you noted before (if it isn’t, do the needed corrections) ;
- set “monitor series”=yes, “monitor episodes”=all and click on the blue button “update” ;
- when the operation of the previous point is finished, update your library : sonarr should remove the episodes of the deleted shows one by one (you can see this “live” in your list of shows, the colored gauges change) ;
- when the operation of the previous point is finished, you should have 0 episodes for all the shows of the HDD ;
- go to the settings of sonarr, and change the drone factory folder : set it to the one we created on the HDD ;
- go to the “Wanted” list (big icon on top) and click on “rescan drone factory folder” : this may take some time related to the number of files you have. You can follow the progression in your list of shows, while the gauges rise one by one for all the videos re-imported ;
- after this, verify the folder “factory” we’ve created : the episodes that left, if any, are :
- the smallest ones in case of multiple files for 1 episode - the best one was imported ;
- the unreadable ones, corrupted ;
- those with an unrecognized name - change them manually and re-launch the scan of the factory folder
That’s it, i have my brand new folders, perfectly renamed and organized.
The status “missing” is right for all my shows.
From here, with the “Season Pass”, you can unmonitor the completed shows, unmonitor the downloaded episodes, and leave monitored the missing ones so you can use the “search missing” feature of sonarr for all of them.
Note that we changed the profile of all the shows at the beginning to be sure that we re-imported all the video files that we had : maybe you want to rechange this if you’re only interested in HD.
Don’t forget to reset your config in sonarr for the drone factory folder as it was before.
Profile “any” : create a profile “any” where all the types, from SD to 1080p, are checked and set the cutoff equal to the lowest type.
Rename with mediainfo data : in the settings, first tab “Media Management”, activate the advanced settings if it’s not, and use something like this as “Standard Episode Format” :
{Series.CleanTitle}_S{season:00}E{episode:00}_{Episode.CleanTitle}_[{Quality.Full}].[{MediaInfo.Full}]