@alfrix Thank you for this script. Even though RetroArch now has a built-in core updater I still find this script useful for automating the core updates.
I also wanted to share some tweaks I made that fix the error messages that are often produced as noted by @rodww.
Those errors will go away if you replace lines 34-36 with the following:
$timestamp_old=$(Get-Content "$cores_path\.timestamps.old" | Select-String -pattern "(?<=\s)$corename")
$timestamp_new=$(Get-Content "$cores_path\.timestamps.new"| Select-String -pattern "(?<=\s)$corename")
if ( $timestamp_new -ne $null )
{
$current_timestamp=$timestamp_new.ToString($timestamp_new).Split(" ")[0]
}
The error “You cannot call a method on a null-valued expression” will happen if you have cores that have been renamed or discontinued. An example of this is that “4do_libretro” has been renamed to “opera_libretro”. In such a case there will be no entry for it in the file “.timestamps.new” so the value for “$timestamp_new” will be null and you will get that error. By adding the if statement that only sets the value for “$current_timestamp” if the value of “$timestamp_new” is not null, you will avoid those errors. What would be great is if there is a way to determine if a core you have has indeed had a name change and then remove the old one and download the newly named one but that seems like quite a bit of work.
The error "Cannot find an overload for “ToString” and the argument count: “1"” is caused when The operation that sets the value for “$timestamp_old” or “$timestamp_new” finds more than one match for the core name in “.timestamps.old” or “.timestamps.old” files. An example of this is that when checking the timestamp for “mame_libretro” currently the value of “$timestamp_new” will be set to:
2020-04-05 8e456fab hbmame_libretro.dll.zip
2020-07-29 e550ad3e mame_libretro.dll.zip
This is because the string “mame_libretro.dll” is also contained in “hbmame_libretro.dll” so there are two matches. This can be fixed by doing a regex match instead of a simple match when parsing “.timestamps.old” and “.timestamps.old” and setting the values of “$timestamp_old” and “$timestamp_new”. I used “(?<=\s)$corename” as the pattern to match which basically matches the value of “$corename” only when it is preceded by a space. Because of the format of “.timestamps.old” and “.timestamps.old” this will make sure that the core names are only matched where intended and not when they also happen to be a part of any other string in those files.
I hope this is helpful.