@@ -19,9 +19,10 @@ The script is shared under the GPLv3 License http://www.gnu.org/licenses/gpl-3.0
1919 along with this program. If not, see <https://www.gnu.org/licenses/>.
2020
2121If you encounter any bugs, or have any ideas on how to improve this script hit me up at [email protected] 22- Version: 2.3
2322#>
2423
24+ $Version = 2.3
25+
2526# Create saves Folder
2627if (! (Test-Path " $PSScriptRoot \data" - PathType Container)) {
2728 New-Item - ItemType Directory - Force - Path " $PSScriptRoot \data" | Out-Null
@@ -298,5 +299,37 @@ Else {
298299 }
299300}
300301
302+ function Update-Script {
303+ $checkVersion = " https://api.github.com/repos/EstoyMejor/Rainbow-Six-Save-File-Swapper/releases/latest"
304+
305+ $HREF = Invoke-WebRequest - Uri $checkVersion
306+ $content = $HREF.Content
307+ $versionzipballLink = $content.Substring ($content.IndexOf (" zipball_url" ) + 14 , 81 )
308+ $versionName = $content.Substring ($content.IndexOf (" tag_name" ) + 10 , 3 )
309+ $regex = ' https:\/\/api\.github\.com\/repos\/EstoyMejor\/Rainbow-Six-Save-File-Swapper\/zipball\/[0-9]+\.[0-9]+(\.[0-9])*'
310+ $validLink = false
311+
312+ if ($versionzipballLink -match $regex -and $versionName -notmatch $Version ) {
313+ $validLink = true
314+ Write-Output " New version found!"
315+ }
316+
317+ if ($validLink ) {
318+ if (Test-Path " $PSScriptRoot \R6_SaveFileSwap.ps1" - PathType Leaf) {
319+ Rename-Item - Path " $PSScriptRoot \R6_SaveFileSwap.ps1" - NewName " R6_SaveFileSwap_$Version .ps1"
320+ Write-Output " Renamed currently running version.`n File name is R6_SaveFileSwap_$Version .ps1, feel free to delete at your digression. "
321+ }
322+
323+ Write-Output " Downloading update..."
324+ Invoke-WebRequest - Uri $versionzipballLink - OutFile " $PSScriptRoot \update.zip"
325+ Expand-Archive - Path " $PSScriptRoot \update.zip" - DestinationPath " $PSScriptRoot " - Force
326+ Write-Output " Done."
327+ Read-Host " Press enter to exit. Restart the script Manually please."
328+ } else {
329+ Write-Output " No new version found, or error on fetching new Version.`n If you want to make sure, check the repo manually:`n https://github.com/EstoyMejor/Rainbow-Six-Save-File-Swapper/releases/latest"
330+ }
331+ }
332+
301333# Open the Menu
334+ Update-Script
302335Open-Menu
0 commit comments