MCFileRemover - Remove Files From MC Based On a Playlist
I made a new version of a little command line utility I've been using. You give it a Playlist (usually a Smartlist) and it goes through the list and removes the files from MC.
Download: MCUtilities
Change Log: MCFileRemover-ChangeLog.txt
Overview
The default mode is to only remove files that are already missing on disk (broken links). It is a workaround I made to deal with the fact that I both:
- Can't use the regular Remove Missing Links feature (because I use a lot of external disks that all share the same drive letter, which is my own fault)
- Schedule certain TV Shows to auto-delete after a certain amount of time, which causes regular broken links.
I've enhanced it to add some additional features that might make it useful for others. In addition to the default mode (where you simply give it a Playlist to scan, and it removes any broken links it finds in said Playlist), it can now remove even files that still exist on disk, and delete those files from disk if you'd like. This could be very handy if you want to schedule MC to auto-delete certain shows based on certain criteria. For example: I use it for old episodes of News programs, kids shows like Caillou that I only want to keep "so many" of, and things like The Daily Show where I won't watch them anyway once they're of "a certain age". You can probably think of other uses.
I tried to make it pretty "safe" to use in an automated fashion. The idea is that you should run it via the Windows Task Scheduler on some kind of recurring basis (mine is set up daily in the middle of the night). You give it a Playlist, and it removes the files. However, for safety I added a few things:
- If you enable the options to remove existing files, or delete files from disk, then it adds a small (300ms) delay between deleting each file, to give you a chance to stop it if you realize it has gone amok.
- It has a hard-coded limit of 20 files maximum. If you need to regularly remove more than that number, I suggest you run it multiple times or more frequently. It doesn't take long to run and uses almost no resources (other than MC itself).
- If you really insist, you can specify the --OverrideLimits option, but this will require you to confirm the operation interactively (no scheduled use).
If people are actually using this, and complain about the limit of 20, that could be changed. I just set that because it is a nice round number that works for me, and it limits the "loss" should you seriously mess up the Smartlist you use to "feed" the application (causing it to put the wrong files in the list, or worse, your whole Library).
Instructions
Command Line Instructions
Usage: --playlist="Path\to\MC Playlist" [OPTIONS] Remove all files from JRiver Media Center that are in the provided playlist. If no --playlist is provided an error is returned. Options: -p, --playlist=PLAYLIST the path to the PLAYLIST to process in Media Center. --RemoveExistingFiles this allows files that exist on disk to be removed as well as missing files. --DeleteFiles this deletes the files from disk after removing them from Media Center. --DeleteSidecars this also deletes sidecar files from disk (only valid when DeleteFiles is also enabled). --OverrideLimits the normal behavior is to limit the application to a maximum of 20 file removals. This overrides this limit and allows unlimited removals in a single pass. -h, --help show this message and exit
Playlist:
Playlists are specified using the "path" in Media Center starting from the Playlists top-level view. So, for example, to select the File Remover list in the Utilities playlist folder, you'd specify:
--playlist="Utilities\File Remover"
You must specify a Playlist to use or it won't do anything (and will throw an error).
Sidecar Files:
MCFileRemover now has (as of v1.0.6) a command line option that deletes sidecar files in addition to the file(s) specified by the playlist. This option is ignored if both --DeleteFiles and --RemoveExistingFiles are not also enabled.
Files are determined to be sidecars (and therefore deleted) if they are in the same directory as the source file (the search is not recursive) and they match one of the following patterns:
- [Source Filename Without Extension].jpg
- [Source Filename Without Extension].nfo
- [Source Filename Without Extension]_[Original Extension]_JRSidecar.xml
- [Source Filename Without Extension]_ts_JRSidecar.xml
- [Source Filename Without Extension]_mpg_JRSidecar.xml
- [Source Filename With Extension].properties
The .properties files are metadata sidecars created by SageTV. The .nfo sidecars are annoying files that are often in downloads (they might be used by other PVR applications too).
I added the explicit checks for _ts_JRSidecar.xml and _mpg_JRSidecar.xml because on my own setup, I transcode many of these files from TS or MPG to other container formats, which leaves these old Sidecar files "orphaned" in the source directory otherwise. I'd originally considered adding a search for [Source Filename Without Extension] + _*_JRSidecar.xml (with smarts to look for only valid filename extensions at the wildcard), but I decided that explicitly checking only for filenames where this is likely to occur is safer.
If you need additional patterns for common sidecar files, please feel free to ask. Adding additional similar patterns should be simple.
Example
c:\Program Files (x86)\MCUtilities>MCFileRemover.exe --playlist="Testers\File Remover Test" --RemoveExistingFiles --DeleteFiles --DeleteSidecars ---------------------------------------- MCFileRemover (by glynor) v1.0.6 ---------------------------------------- Selected Options: Playlist Path: Testers\File Remover Test Remove Files that Exist: True Delete Files from Disk: True Delete Sidecar Files from Disk: True Processing Limits: 20 Connecting to running MC instance... Success. Removing Files in Playlist: File Remover Test Number of Files to Process: 10 Removing file: M:\Recordings\BBCWorldNews-6926108-0.mpg File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: BBCWorldNews-6926108-0_mpg_JRSidecar.xml File Deleted. * Deleting: BBCWorldNews-6926108-0.mpg File Deleted. Removing file: M:\Recordings\FoodNetworkStar-S08E07-MeetthePressUre-10207731-0.mpg File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: FoodNetworkStar-S08E07-MeetthePressUre-10207731-0_mpg_JRSidecar.xml File Deleted. * Deleting: FoodNetworkStar-S08E07-MeetthePressUre-10207731-0.mpg File Deleted. Removing file: M:\Recordings\TheColbertReport-S09E149-AndrewBacevich-17375246-0.ts File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: TheColbertReport-S09E149-AndrewBacevich-17375246-0.ts.properties File Deleted. * Deleting: TheColbertReport-S09E149-AndrewBacevich-17375246-0_ts_JRSidecar.xml File Deleted. * Deleting: TheColbertReport-S09E149-AndrewBacevich-17375246-0.ts File Deleted. Removing file: M:\Recordings\SuperWhy-S01E52-HanselandGretelAHealthyAdventure-17880077-0.ts File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: SuperWhy-S01E52-HanselandGretelAHealthyAdventure-17880077-0.jpg File Deleted. * Deleting: SuperWhy-S01E52-HanselandGretelAHealthyAdventure-17880077-0.ts.properties File Deleted. * Deleting: SuperWhy-S01E52-HanselandGretelAHealthyAdventure-17880077-0_ts_JRSidecar.xml File Deleted. * Deleting: SuperWhy-S01E52-HanselandGretelAHealthyAdventure-17880077-0.ts File Deleted. Removing file: M:\Recordings\Jeopardy-S30E122-BattleoftheDecades1990s-20261538-0.mpg File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: Jeopardy-S30E122-BattleoftheDecades1990s-20261538-0.mpg.properties File Deleted. * Deleting: Jeopardy-S30E122-BattleoftheDecades1990s-20261538-0_mpg_JRSidecar.xml File Deleted. * Deleting: Jeopardy-S30E122-BattleoftheDecades1990s-20261538-0.mpg File Deleted. Removing file: M:\Recordings\Jeopardy-S30E123-BattleoftheDecades1990s-20281491-0.mp4 File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: Jeopardy-S30E123-BattleoftheDecades1990s-20281491-0_mp4_JRSidecar.xml File Deleted. * Deleting: Jeopardy-S30E123-BattleoftheDecades1990s-20281491-0_mpg_JRSidecar.xml File Deleted. * Deleting: Jeopardy-S30E123-BattleoftheDecades1990s-20281491-0.mp4 File Deleted. Removing file: M:\Recordings\Caillou-CailloutheMagnificent-20389152-0.mp4 File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: Caillou-CailloutheMagnificent-20389152-0_mp4_JRSidecar.xml File Deleted. * Deleting: Caillou-CailloutheMagnificent-20389152-0_mpg_JRSidecar.xml File Deleted. * Deleting: Caillou-CailloutheMagnificent-20389152-0.mp4 File Deleted. Removing file: M:\Recordings\TeamUmizoomi-S02E09-CrazySkates-20546485-0.mp4 File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: TeamUmizoomi-S02E09-CrazySkates-20546485-0.jpg File Deleted. * Deleting: TeamUmizoomi-S02E09-CrazySkates-20546485-0_mp4_JRSidecar.xml File Deleted. * Deleting: TeamUmizoomi-S02E09-CrazySkates-20546485-0_ts_JRSidecar.xml File Deleted. * Deleting: TeamUmizoomi-S02E09-CrazySkates-20546485-0.mp4 File Deleted. Removing file: M:\Recordings\BBCWorldNews-20757092-0.mp4 File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: BBCWorldNews-20757092-0_mp4_JRSidecar.xml File Deleted. * Deleting: BBCWorldNews-20757092-0_mpg_JRSidecar.xml File Deleted. * Deleting: BBCWorldNews-20757092-0.mp4 File Deleted. Removing file: M:\Recordings\BBCWorldNews-20779366-0.mp4 File exists on disk. Remove Existing flag is: True File removed. Deleting file from disk (flag is: True) * Deleting: BBCWorldNews-20779366-0_mp4_JRSidecar.xml File Deleted. * Deleting: BBCWorldNews-20779366-0_mpg_JRSidecar.xml File Deleted. * Deleting: BBCWorldNews-20779366-0.mp4 File Deleted. Processing finished. Status: Completed Files Removed: 10 Files Skipped: 0 ----------------------------------------