-
|
Any PowerShell gurus who might have an easy solution to this? I love using the script provided by @habedi to ensure I have all game files backed up, but I wish there was a way to tell How would I go about modifying the script to include maybe an array of files that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
@pa-0 Oh, just saw that you use I think you can use this version of # To run the script, open PowerShell and execute the following command:
# Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; .\download_all_games.ps1
# Colors
$RED = "`e[31m"
$GREEN = "`e[32m"
$YELLOW = "`e[33m"
$NC = "`e[0m" # No Color
Write-Host "${GREEN}===================== Download All Games (Windows Powershell Version) ======================${NC}"
Write-Host "${GREEN}The code in this script downloads all games owned by the user on GOG.com with given options.${NC}"
Write-Host "${GREEN}============================================================================================${NC}"
$env:DEBUG_GOGG = 1 # Debug mode enabled
$GOGG = ".\bin/gogg" # Path to Gogg's executable file (for example, ".\bin\gogg")
# Download options
$LANG = "en" # Language English
$PLATFORM = "windows" # Platform Windows
$INCLUDE_DLC = 1 # Include DLCs
$INCLUDE_EXTRA_CONTENT = 1 # Include extra content
$RESUME_DOWNLOAD = 1 # Resume download
$NUM_THREADS = 4 # Number of worker threads for downloading
$FLATTEN = 1 # Flatten directory structure
$OUTPUT_DIR = "./games" # Output directory
# Skip-list: file names (exact names) to remove after download. You can add filenames like 'CP_163.zip'
# Supports exact filename matches. If you want wildcard matching, use patterns or extend the script.
$SKIP_FILES = @(
'CP_163.zip'
)
# Dry-run: set to $true to only print what would be removed, without deleting files
$DRY_RUN = $false
# Function to clean up the CSV file
function Cleanup
{
if ($latest_csv)
{
Remove-Item -Force $latest_csv
if ($?)
{
Write-Host "${RED}Cleanup: removed $latest_csv${NC}"
}
}
}
# Update game catalogue and export it to a CSV file
& $GOGG catalogue refresh
& $GOGG catalogue export ./ --format=csv
# Find the newest catalogue file
$latest_csv = Get-ChildItem -Path . -Filter "gogg_catalogue_*.csv" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
# Check if the catalogue file exists
if (-not $latest_csv)
{
Write-Host "${RED}No CSV file found.${NC}"
exit 1
}
Write-Host "${GREEN}Using catalogue file: $( $latest_csv.Name )${NC}"
# Download each game listed in catalogue file, skipping the first line
Get-Content $latest_csv.FullName | Select-Object -Skip 1 | ForEach-Object {
$fields = $_ -split ","
$game_id = $fields[0]
$game_title = $fields[1]
Write-Host "${YELLOW}Game ID: $game_id, Title: $game_title${NC}"
& $GOGG download $game_id $OUTPUT_DIR --platform=$PLATFORM --lang=$LANG `
--dlcs=$INCLUDE_DLC --extras=$INCLUDE_EXTRA_CONTENT --resume=$RESUME_DOWNLOAD --threads=$NUM_THREADS `
--flatten=$FLATTEN
# If skip-list is configured, try to find and remove matching files from the output directory
if ($SKIP_FILES -and $SKIP_FILES.Count -gt 0)
{
Write-Host "${YELLOW}Checking for files to skip (dry-run = $DRY_RUN)...${NC}"
# Find files in the output directory whose Name matches any entry in $SKIP_FILES
$found = Get-ChildItem -Path $OUTPUT_DIR -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $SKIP_FILES -contains $_.Name }
if ($found -and $found.Count -gt 0)
{
foreach ($f in $found)
{
if ($DRY_RUN)
{
Write-Host "${YELLOW}Would remove: $($f.FullName)${NC}"
}
else
{
try
{
Remove-Item -Force $f.FullName -ErrorAction Stop
Write-Host "${RED}Removed skipped file: $($f.FullName)${NC}"
}
catch
{
Write-Host "${RED}Failed to remove $($f.FullName): $($_.Exception.Message)${NC}"
}
}
}
}
else
{
Write-Host "${GREEN}No skipped files found for this game.${NC}"
}
}
Start-Sleep -Seconds 1
}
# Clean up
Cleanup |
Beta Was this translation helpful? Give feedback.

@pa-0
What script do you exactly use for downloading/archiving game files?Oh, just saw that you use
download_all_games.ps1.I think you can use this version of
download_all_games.ps1, which includes aSKIP_FILESvariable that is a list. Any file names in the list should be skipped (not downloaded).