function TouchFiles($path = $pwd, [string[]]$exclude)
{
    foreach ($item in Get-ChildItem $path)
    {
        if ($exclude | Where {$item -like $_}) { continue }
 
		#Write-Output $item.FullName
		
        if (Test-Path $item.FullName -PathType Container)
        {
			(Get-Item $item.FullName).CreationTime=(Get-Date)
			(Get-Item $item.FullName).LastWriteTime=(Get-Date)
			(Get-Item $item.FullName).LastAccessTime=(Get-Date)
			
            GetFiles $item.FullName $exclude
        }else{
			$file = (Get-Item $item.FullName)
			$file.CreationTime = (Get-Date)
			$file.LastWriteTime = (Get-Date)
			$file.LastAccessTime = (Get-Date)
 
		}
    }
} 
 
$protectedFolders = @("adv_duplicator", "advdupe2", "expression2", "e2files", "bhop", "advdupe2", "starfall", "pac3")
 
$foldersToDelete = @("garrysmod\\cache", "garrysmod\\download", "garrysmod\\downloadlists", "garrysmod\\screenshots", "garrysmod\\data")
$filesToDelete = @("garrysmod\\sv.db", "garrysmod\\cl.db", "garrysmod\\mn.db")
 
$garrysModPath = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\"
 
foreach ($folder in $foldersToDelete) {
    $folderPath = Join-Path $garrysModPath $folder
    if (Test-Path $folderPath -PathType Container) {
        foreach ($subfolder in Get-ChildItem -Path $folderPath -Directory) {
            $subfolderName = $subfolder.Name
            if ($protectedFolders -notcontains $subfolderName) {
                $subfolderPath = Join-Path $folderPath $subfolderName
                Remove-Item -Path $subfolderPath -Recurse -Force
                #Write-Host "Deleted folder: $subfolderPath"
            } else {
                Write-Host "Skipping deletion of protected folder: $subfolderPath"
            }
 
            Remove-Item -Path $folderPath\* -Exclude $protectedFolders -Force
            #Write-Host "Deleted files in folder: $folderPath"
        }
    } else {
        Write-Host "Folder not found: $folderPath"
    }
}
 
 
foreach ($file in $filesToDelete) {
    $filePath = Join-Path $garrysModPath $file
    if (Test-Path $filePath -PathType Leaf) {
        Remove-Item -Path $filePath -Force
        Write-Host "Deleted file: $filePath"
    }
}
 
TouchFiles $garrysModPath