Ok,
I have tried and tested this script. Works fine. You must use a Global TempFolder. Paste it in the :
StopGlobalUserFeatures(){
Log("StopGlobalUserFeatures - Starting")
; INSERT CODE HERE
So that it runs everytime you exit a game.
; THIS IS THE START OF TEMP STUFF script-----------------------------------------------------------------------------------------
IniRead, GTPath, .\Settings\Global RocketLauncher.ini, 7z, 7z_Extract_Path ; get global path from Global RocketLauncher.ini
; This top script removes empty folders to start with
SetBatchLines, -1 ; Make the operation run at maximum speed.
path = %GTPath%
folders_deleted = 0
Loop, %Path%\*, 2 ;loop relative folder path
{
currentfolder:=A_LoopFileFullPath
FolderSizeKB = 0
Loop, %CurrentFolder%\*.*, , 1
{
FolderSizeKB += %A_LoopFileSizeKB%
}
;msgbox %CurrentFolder%`n%FolderSizeKB% ;folder sizes
if FolderSizeKB < 5 ;any folder less than 5kb gets deleted.
{
fileremovedir,%CurrentFolder%,1
folders_deleted+=1
}
}
;go to next part for dates
;---------------------------------------------------------------------------------------------------------------------------
total = ;variable to keep tally of number of folders
FileList = ;clear variable
Loop, %Path%\*.*,2 ;loop temp folder
{
{
; create a list of system named folders in temp
folder = %A_LoopFileName%
Sort, folder ; sort the list
}
gameList = ;clear variable
Loop, %Path%\%folder%\*.*,2 ;loop temp path\system name to get list of game folders in each system folder
{
; create a list of those files consisting of the time the file was created and the file name separated by tab
gameList = %gameList%%A_LoopFileTimeCreated%`t%A_LoopFileName%`n
Sort, gameList ; sort the list by time created
total:= A_Index
sleep, 200
if total > 5 ;change this if you want more or less games left undeleted this needs to match the If Name = 5 line below. This means that if there are more than 5 game folders continue
Loop, parse, gameList, `n,`r ;loop through the game folder names
{
if A_LoopField =
continue
StringSplit, FileItem, A_LoopField, %A_Tab% ; Split the list items into two parts at the tab character
If not ErrorLevel
sleep, 200
{
Name := total - A_Index ; Name = total number of games - the number of loop
sleep, 200
fileremovedir,%Path%\%folder%\%FileItem2%,1 ; delete the game folder
}
If Name = 5 ;change this if you want more or less games left undeleted - This leaves 5 games per system undeleted (Stops the loop at 5 as the loop counts down until there is only 5 left)
break ;stop looping
}
}
}
return ; do nothing we're done
; THIS IS THE END OF TEMP STUFF script-----------------------------------------------------------------------------------------