This is the Cs version of the script posted by michaelkrieger at jellyfin/jellyfin#1907 (comment) to cleanup the collection.xml for missing link entires.
To run this on linus, ensure you have a dotnet version installed.
https://learn.microsoft.com/en-us/dotnet/core/install/linux
or for the most part, this oneliner will install dotnet on your system:
curl -sL "https://dot.net/v1/dotnet-install.sh" | bash
Most should have any one dotnet version installed on the system. However i recommand using the latest version (Net7) or at least Net6.
Visit the mirosoft page https://dotnet.microsoft.com/en-us/download/dotnet
and download it or verifiy that you have the latest dotnet version installed
by opening a new commandline and running:
dotnet --info
this should list under ".NET SDKs installed" at least some versions starting with "6.0.000" or higher.
You can also just use this command to ensure dotnet7 is installed
winget install Microsoft.DotNet.SDK.7
After the install has been completed, navigate to a new folder and create a new c# project via:
dotnet new console
then download this script and download it in the same directory you just created the new project in like this:
curl "https://gist.githubusercontent.com/JPVenson/e765d97c3c1eb92fb11f0856c6034e6a/raw/5200079b939c7be8e5b2da274d7229a0c4dd5bed/program.cs" -o Program.cs
The script can be run Interactivly or controlled via commandline arguments or enviorment variables.
The script can dryrun without applying modifications.
Syntax: whatif=y
[EnviormentVariable] [arguments]
Replaces the root of the media path as read from the collection with a fixed other. Helpfull when you BACKUP your collection folder and move it to another system
Syntax: targetPathSubsitution=ORIGINAL:NEW
[EnviormentVariable] [arguments]
Path to the directory where the collection.xml
files are located in. Usually under you config directory \data\collections
.
Syntax: input=PATH
[Interactive] [EnviormentVariable] [arguments]
The path to the root of your media.
Syntax: mediaRoot=PATH
[Interactive] [EnviormentVariable] [arguments]
after that, compile and run this file with:
dotnet run
To add arguments, use a blank --
to seperate arguments to the dotnet call and the app.
For example, this sets the RunDry flag and substitutes the root path \mnt\media
with X:\videos\store
in a case where you run the script on a windows host and want to modify the collections in the linux path format.
dotnet run -- whatif=y "targetPathSubsitution=\mnt\media\:X:\videos\store"