Skip to content

Instantly share code, notes, and snippets.

@fredimachado
Last active November 14, 2018 11:04
Show Gist options
  • Save fredimachado/1a3d36f34e786a423328a347ff11215a to your computer and use it in GitHub Desktop.
Save fredimachado/1a3d36f34e786a423328a347ff11215a to your computer and use it in GitHub Desktop.
Delete duplicate Fortnite replay files based on the date on the file name
# !! USE IT AT YOUR OWN RISK !!
#
# Run this script after Fixing the replay files and making sure you can watch them in the game
# This script will delete duplicate replay files based on the date on the name of the file
#
# Script to fix replay files: https://gist.github.com/fredimachado/19a489f6dccdb9e2d18b482bed87059d
#
# Copy all this content, paste in notepad and save as a ps1 file, example: Delete-Duplicate-Fortnite-Replays.ps1
# Then, open the folder containing the script, right click it and choose: Run With Powershell
# If it doesnt run, follow this: https://superuser.com/questions/106360/how-to-enable-execution-of-powershell-scripts
$LocalAppDataFolder = "$env:LOCALAPPDATA"
$FortniteReplaysFolder = $LocalAppDataFolder + "\FortniteGame\Saved\Demos"
$replayList = New-Object System.Collections.ArrayList
Get-Childitem $FortniteReplaysFolder -Filter *.replay |
Sort LastWriteTime -Descending |
Foreach-Object {
$match = ""
if ($_.Name -match "\.\d{2}\.\d{2}-\d{2}\.\d{2}\.\d{2}\.replay") {
$match = $matches[0]
if ($replayList.Contains($match)) {
Write-Host "Deleting duplicated replay: $($_.FullName)"
Remove-Item $_.FullName
return
}
$replayList.Add($match) | Out-Null
}
}
"Press a key..."; $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment