fs25save/uploadSaves.ps1

46 lines
1.7 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

param(
[string]$saveFolder = "savegame2" # Папка с сейвом по умолчанию
)
# Получаем путь к текущей директории (откуда был запущен скрипт)
$currentDir = Get-Location
# Путь к родительской директории (папка FarmingSimulator2025)
$parentDir = Split-Path -Path $currentDir -Parent # Поднимаемся на уровень выше
# Путь к папке с сейвом (savegame2)
$sourcePath = Join-Path -Path $parentDir -ChildPath $saveFolder
# Путь к папке, куда копируются файлы (текущая директория)
$gitPath = $currentDir
Write-Host $currentDir -ForegroundColor Yellow
Write-Host $parentDir -ForegroundColor Yellow
Write-Host $sourcePath -ForegroundColor Yellow
# Проверка существования папки с сейвом
if (-not (Test-Path $sourcePath)) {
Write-Host "❌ Папка сейва не найдена: $sourcePath" -ForegroundColor Red
exit
}
# Копирование файлов
Write-Host "📂 Копирование сейва из '$sourcePath' в текущую папку..."
Copy-Item -Path "$sourcePath\*" -Destination $gitPath -Recurse -Force
# Переход в текущую папку
Set-Location $gitPath
# Добавление изменений в Git
git add .
# Формирование текущего времени для коммита
$timeStamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
# Создание коммита и пуш
git commit -m "Сейв от $timeStamp"
git push
Write-Host "✅ Сейв синхронизирован и запушен в репозиторий." -ForegroundColor Green