Skip to content

Commit

Permalink
CopyGames
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoonDorise committed Oct 17, 2024
1 parent cad0133 commit ec11d5c
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions functions/ToolScripts/emuDeckCopyGames.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
function CreateStructureUSB {
param(
[string]$destination
)

# Crear directorios si no existen
New-Item -Path "$destination\bios\" -ItemType Directory -Force
New-Item -Path "$destination\bios\dc" -ItemType Directory -Force
New-Item -Path "$destination\bios\yuzu\firmware" -ItemType Directory -Force
New-Item -Path "$destination\bios\yuzu\keys" -ItemType Directory -Force
New-Item -Path "$destination\roms\" -ItemType Directory -Force

# Crear el archivo readme.txt con el contenido
$readmeContent = @"
# Where to put your bios?
First of all, don't create any new subdirectory. ***
# System -> folder
Playstation 1 / Duckstation -> bios/
Playstation 2 / PCSX2 -> bios/
Nintendo DS / melonDS -> bios/
Playstation 3 / RPCS3 -> Download it from https://www.playstation.com/en-us/support/hardware/ps3/system-software/
Dreamcast / RetroArch -> bios/dc
Switch / Yuzu -> bios/yuzu/firmware and bios/yuzu/keys
Those are the only mandatory bios, the rest are optional
"@

$readmePath = "$destination\bios\readme.txt"
$readmeContent | Out-File -FilePath $readmePath -Encoding UTF8

# Copiar archivos excluyendo los archivos .txt
robocopy "$env:APPDATA\EmuDeck\backend\roms" "$destination\roms" /E /XO /XF *.txt
if ($LASTEXITCODE -eq 0) {
Write-Output "true"
} else {
Write-Output "false"
}

}



function CopyGames {
param(
[string]$origin
)

# Calcular espacio necesario
$neededSpace = (Get-ChildItem -Recurse -Force -File -Path $origin | Measure-Object -Sum Length).Sum
$neededSpaceInHuman = [math]::round($neededSpace / 1GB, 2)


# Obtener la letra de la unidad desde la ruta $emulationPath
$driveLetter = (Split-Path -Qualifier $emulationPath)

# Obtener información sobre el volumen de la unidad
$volume = Get-Volume -DriveLetter $driveLetter.TrimEnd(':')

# Obtener el espacio libre en la unidad
$freeSpace = $volume.SizeRemaining
$freeSpaceInHuman = [math]::round($freeSpace / 1GB, 2)
$difference = $freeSpace - $neededSpace

if ($difference -lt 0) {
$text = "Make sure you have enough space in $emulationPath. You need to have at least $neededSpaceInHuman GB available"
Write-Output $text

$ans = Read-Host "Do you want to continue? (yes/no)"
if ($ans -ne "yes") {
exit
}
}

# Copiar archivos
foreach ($entry in Get-ChildItem -Path "$origin\roms\" -Directory) {
$files = Get-ChildItem -Path $entry.FullName -Recurse -File | Where-Object { $_.Extension -ne ".txt" }
if ($files.Count -gt 0) {
$dir = $entry.Name

# Copiar usando robocopy en lugar de rsync
Write-Output "Importing your $dir games to $romsPath"
robocopy "$origin\roms\$entry\" "$romsPath\$dir\" /E /XO /XD .* /NJH /NJS /NP
}
}

# Copiar BIOS
Write-Output "Importing your bios to $biosPath"
robocopy "$origin\bios" "$biosPath" /E /XO /NJH /NJS /NP

# Mensaje de éxito
Write-Output "<b>Success!</b> The contents of your USB Drive have been copied to your Emulation folder"
Start-Sleep -Seconds 3
Write-Output "3... 2... 1..."
}

0 comments on commit ec11d5c

Please sign in to comment.