Playnite Forums
Script for remove deleted games from the playnite list or mark them as uninstalled - Printable Version

+- Playnite Forums (https://playnite.link/forum)
+-- Forum: Extension Database (https://playnite.link/forum/forum-3.html)
+--- Forum: Generic Extensions (https://playnite.link/forum/forum-6.html)
+--- Thread: Script for remove deleted games from the playnite list or mark them as uninstalled (/thread-102.html)



Script for remove deleted games from the playnite list or mark them as uninstalled - Itegnis - 01-12-2020

Download:

RDGScript This is a script that will collect all the “missing” games, and then provide the user with a dialog box to select which ones to remove from Playnite.
RDGScript_Mark This is a version of the script that will collect all the “missing” games and then mark them as uninstalled instead of deleting them.

For Activate, click on Extensions -> Remove deleted games from the list

Update 1.2
- Now supports Steam games

Update 1.1
- Now supports Windows Store apps
- Fixed a bug that displayed the number of all marked games
- "Mark" version now has a dialog box
- Alphabetically sorting in dialog box

Thanks steve-o for description
Updated 05.05.2020


RE: Script for remove deleted games from the playnite list - CriticalComposer - 01-13-2020

What exactly does this do?


RE: Script for remove deleted games from the playnite list - Itegnis - 01-14-2020

(01-13-2020, 01:23 PM)CriticalComposer Wrote: What exactly does this do?
Removes from the list manually added games that have been deleted from your hard drive?


RE: Script for remove deleted games from the playnite list - steve-o - 01-14-2020

I think he was asking if you could go into more detail about your script and how it works, features, etc.

For example, from a quick glance at the github code, it looks like the script will collect all the "missing" games and then present the user with a dialog to choose which ones should be removed from Playnite? So, it doesn't just run headlessly and automatically remove stuff that doesn't line up. If I was reading the code correctly anyway, which I very well may not have been.

Show off your work! Get us excitied! Tell us how it works and what (if any) options it provides.


RE: Script for remove deleted games from the playnite list - CriticalComposer - 01-14-2020

Nope. I was literally trying to figure out what a deleted game was. It never dawned on me that someone would want to remove a DRM-Free game from their Playnite library just because it wasn't installed anymore.


RE: Script for remove deleted games from the playnite list - darklinkpower - 01-15-2020

I think it would be a good idea to mark them as unninstalled instead of deleting them. If you unninstall a DRM free game, you may want to keep it in your library to know you have it and mark it as installed when the game is installed again. Also it would be great if it would check if said games are there again so it could check them as installed again in an automated way.

And I agree with steve-o, it would be great if you wrote a simple description in the OP about the plugin and some screenshots.


RE: Script for remove deleted games from the playnite list - DonkeyOatay - 02-16-2020

I agree wiith darklinkpower but given the lack of response it looks like the OP has disappeared unfortunately.

Is anyone else able to say what would need to change in order for the script to mark as uninstalled rather than remove?

The bit of the script that I believe removes the game is:

$buttonRemoveSelected_Click={
$num = 0
foreach ($item in $checkedlistbox1.CheckedItems)
{
$PlayniteApi.Database.Games.Remove($item.Id)
$num = $num + 1
}
$formRDGScriptMenu.Close()
$PlayniteAPI.Dialogs.ShowMessage("Removed " + $num + " games of the list")

But having no experience of programming or APIs I have no idea what to put in the place of "PlayniteApi.Database.Games.Remove".

Looking at the documentation the field appears to be 'IsInstalled' but that's as far as my abilitities take me.


RE: Script for remove deleted games from the playnite list - Crow - 02-16-2020

Instead of:

$PlayniteApi.Database.Games.Remove($item.Id)

use:

$item.IsInstalled = $false
$PlayniteApi.Database.Games.Update($item)

I have not tested it Smile


RE: Script for remove deleted games from the playnite list - Itegnis - 02-18-2020

Sorry for missing, I could not do the script since I was engaged in a project at the academy. I added a version that will mark the missing games as deleted
Thanks steve-o for description


RE: Script for remove deleted games from the playnite list - DonkeyOatay - 02-18-2020

Hi Itegnis

Good to see you are still about. I also created a version of your script that marks as uninstalled using Crow's suggestion (there is another thread for it on the forum here) - I hope you don't mind. I will try your version and then remove my one.

One thing I found and which I presume your version will be the same - it will always find games installed by the Windows store or Xbox game pass for PC even whent those games are installed. I presume this is because the Windows store installs them in folders which are protected and therefore the script cannot view the contents. Is there a way around this or can you edit the script to ignore any games in C:\Program Files\Windows Apps maybe?

The other thing I would have like to do would be to arrange the list alphabetically but that is beyond my skills - is it something you can do for both scripts maybe?

Cheers.


RE: Script for remove deleted games from the playnite list - Itegnis - 02-18-2020

(01-15-2020, 12:57 AM)darklinkpower Wrote: I think it would be a good idea to mark them as unninstalled instead of deleting them. If you unninstall a DRM free game, you may want to keep it in your library to know you have it and mark it as installed when the game is installed again. Also it would be great if it would check if said games are there again so it could check them as installed again in an automated way.

And I agree with steve-o, it would be great if you wrote a simple description in the OP about the plugin and some screenshots.
I can’t make the script check if the games are installed again, since they are tied to the installation path, so if the path will differ even by a character, it will not count it installed when checking. That is why I initially did not intend to even mark the games as deleted. If there are ideas how to do this, I will listen.

Sorry for my English. I'm from Ukraine Big Grin


(02-18-2020, 02:33 PM)Donkeyfumbler Wrote: Hi Itegnis

Good to see you are still about. I also created a version of your script that marks as uninstalled using Crow's suggestion (there is another thread for it on the forum here) - I hope you don't mind. I will try your version and then remove my one.

One thing I found and which I presume your version will be the same - it will always find games installed by the Windows store or Xbox game pass for PC even whent those games are installed. I presume this is because the Windows store installs them in folders which are protected and therefore the script cannot view the contents. Is there a way around this or can you edit the script to ignore any games in C:\Program Files\Windows Apps maybe?

The other thing I would have like to do would be to arrange the list alphabetically but that is beyond my skills - is it something you can do for both scripts maybe?

Cheers.
Regarding the Windows store of games, I will try to do something, but I do not promise.

Sorting the games alphabetically in a dialog box is hard for me, but I can try. But most likely this will increase the time the script runs.

I would also like to ask if it is worth leaving a dialog box for the version with marks?

And I do not mind that you edit the code of my script at your discretion and publish it. The only thing I ask is to leave your code open to others. Perhaps with the help of the community, it will continue to improve.


RE: Script for remove deleted games from the playnite list - DonkeyOatay - 02-18-2020

The alphabetical thing is only a 'nice to have' - if it is hard then don't worry or waste time over it.

I think it is worth leaving the dialog boxes as they are - while I have been using it there have been times when I did not want to to mark all of the games in the list as uninstalled.

Finally, as I use it now I notice another slight issue. If you run it once and mark all games as uninstalled, if you then run the script again it lists all of the same games (even though they are already marked as uninstalled in playnite) because the playaction entry is still there and that is what the script checks for.

I therefore think that the script needs to do one more thing - either

A. it removes the playaction for the game it finds as well as marking it as uninstalled, or
B. it runs a check to see if a game is already marked as uninstalled in Playnite and then doesn't include it in the list if it is.

I suspect that removing the playaction would be the easiest option but again my coding skills are less than basic so I am not able to do either unfortunately!


RE: Script for remove deleted games from the playnite list - Itegnis - 02-18-2020

(02-18-2020, 04:26 PM)Donkeyfumbler Wrote: The alphabetical thing is only a 'nice to have' - if it is hard then don't worry or waste time over it.

I think it is worth leaving the dialog boxes as they are - while I have been using it there have been times when I did not want to to mark all of the games in the list as uninstalled.

Finally, as I use it now I notice another slight issue. If you run it once and mark all games as uninstalled, if you then run the script again it lists all of the same games (even though they are already marked as uninstalled in playnite) because the playaction entry is still there and that is what the script checks for.

I therefore think that the script needs to do one more thing - either

A. it removes the playaction for the game it finds as well as marking it as uninstalled, or
B. it runs a check to see if a game is already marked as uninstalled in Playnite and then doesn't include it in the list if it is.

I suspect that removing the playaction would be the easiest option but again my coding skills are less than basic so I am not able to do either unfortunately!
Released a patch update with support for Windows Store apps, sorting added too.


RE: Script for remove deleted games from the playnite list - DonkeyOatay - 02-18-2020

Hi Itegnis,

I see you also added the check to see if a game is already marked as uninstalled as well.

Great job - thanks very much for putting all of this together, it is much appreciated by me and I'm sure will be by others. It has allowed me quickly and easily mark all of the dummy records I semi-automatically created for all of the Xbox Game Pass Games and Origin Access Games that I have yet to play or download as uninstalled in a few clicks rather than having to edit 400 games individually!

I hope you don't mind, but if you want to correct a couple of spelling mistakes (there is an extra N in uninstalled) then it should be:

"Mark deleted games as uninstalled" instead of "Mark a deleted games as unistalled"

and

"Games that you have deleted. Select the ones you wish to mark as uninstalled and click Mark Selected, or click on the Mark All button to mark all uninstalled games."

instead of

"Games that you have deleted, select the ones you wish to mark as unistalled and click Mark Selected. Or click on the Mark All button for mark all unistalled games."


RE: Script for remove deleted games from the playnite list - Itegnis - 02-19-2020

Fixed


RE: Script for remove deleted games from the playnite list - DonkeyOatay - 02-19-2020

Thanks!


RE: Script for remove deleted games from the playnite list or mark them as uninstalled - Itegnis - 05-05-2020

Update 1.2
- Now supports Steam games


RE: Script for remove deleted games from the playnite list or mark them as uninstalled - DonkeyOatay - 12-13-2020

Hi Itegnis,

Not sure if you are still about, but since Playnite 8 was released I have found that the extension comes up with an error when you run it:

System.Management.Automation.MethodInvocationException: Exception calling "ExpandGameVariables" with "2" argument(s): "The path is not of a legal form." ---> System.ArgumentException: The path is not of a legal form.

Although if you continue after it pops up everything still seems to work (as far as I can tell anyway).