Advertisement
Elec0

Starfield Plugins.txt auto-update

Oct 27th, 2023
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. # Edit this variable:
  3. $starfieldPath = "D:\Games\steamapps\common\Starfield"
  4. # You shouldn't need to edit this
  5. $pluginsTxtPath = "~/AppData/Local/Starfield/Plugins.txt"
  6.  
  7. #
  8. # Don't edit anything below this line
  9. #
  10. $starfieldPathData = "$starfieldPath\Data"
  11. # Check if $starfieldPath exists
  12. if (-not (Test-Path $starfieldPathData)) {
  13.     Write-Host "Error: Cannot find 'Data' folder at '$starfieldPathData'!"
  14.     Write-Host "Press any key to continue"
  15.     [Console]::ReadKey() | Out-Null
  16.     exit
  17. }
  18. # Check if $pluginsTxtPath exists, if not create it
  19. if (-not (Test-Path $pluginsTxtPath)) {
  20.     Write-Host "Creating $pluginsTxtPath"
  21.     New-Item -Path $pluginsTxtPath -ItemType File -Force | Out-Null
  22. }
  23. Write-Host "`n== Plugins.txt old contents =="
  24. Get-Content $pluginsTxtPath
  25. Write-Host "==============================`n"
  26.  
  27. # Get all .esp and .esm files in the Data folder
  28. $plugins = Get-ChildItem $starfieldPathData -Include *.esp, *.esm -Exclude "Starfield.esm" -Recurse -File | ForEach-Object { $_.Name }
  29.  
  30. $firstLine = "# This file is used by Starfield to keep track of your downloaded content. (You HAVE to keep a # on the first line here)"
  31.  
  32. # Write $firstLine to $pluginsTxtPath,
  33. # then append each $plugin to $pluginsTxtPath, formatted as "*$plugin"
  34. $firstLine | Out-File $pluginsTxtPath
  35. $plugins | ForEach-Object { "*$_" | Out-File $pluginsTxtPath -Append }
  36.  
  37. Write-Host "== Plugins.txt new contents =="
  38. Get-Content $pluginsTxtPath
  39. Write-Host "==============================`n"
  40.  
  41. Write-Host "Plugins.txt updated"
  42.  
  43. Write-Host "Press any key to continue"
  44.  
  45. [Console]::ReadKey() | Out-Null
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement