Skip to content

Instantly share code, notes, and snippets.

@Beagon
Created November 25, 2024 20:04
Show Gist options
  • Select an option

  • Save Beagon/47c5fba4c6ec58c1fce4e1fbc735bb6d to your computer and use it in GitHub Desktop.

Select an option

Save Beagon/47c5fba4c6ec58c1fce4e1fbc735bb6d to your computer and use it in GitHub Desktop.
Change media path for Jellyfin
-- This is executed on library.db
-- I merged disk1 and disk2 into one. This meant remove disk1 and disk2/media.
UPDATE TypedBaseItems SET Path = replace(Path, 'disk1/', '');
UPDATE TypedBaseItems SET Path = replace(Path, 'disk2/media/', '');
UPDATE TypedBaseItems SET Images = replace(Images, 'disk1/', '');
UPDATE TypedBaseItems SET Images = replace(Images, 'disk2/media/', '');
UPDATE TypedBaseItems SET data = replace(data, 'disk1/', '');
UPDATE TypedBaseItems SET data = replace(data, 'disk2/media/', '');
UPDATE mediastreams SET Path = replace(Path, 'disk1/', '');
UPDATE mediastreams SET Path = replace(Path, 'disk2/media/', '');
-- This removes the duplicatas. Might not be perfect, but worked for me.
DELETE FROM TypedBaseItems
WHERE EXISTS (
SELECT 1 FROM TypedBaseItems p2
WHERE TypedBaseItems.Path = p2.Path
AND TypedBaseItems.CleanName = p2.CleanName
AND TypedBaseItems.DateLastRefreshed > p2.DateLastRefreshed
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment