Those robocopy's are essentially purging old files. The destination folder is c:\~temp. By using the /move switch and then doing the remove-item, all of those moved files are deleted.
In Powershell the "#" character indicates a comment. So rather than deleting the lines, just change them into comments so that if you find these folders filling up in the future you can just uncomment them and let the purge process work.
C:
CLS
Write-host "Checking for F:\Backup_X"
IF (test-path F:\Backup_X) {
write-host "Backing up \\synologydrive\Data to F:\Backup_X" -foreground Green
robocopy \\synologydrive\data F:\Backup_X\ /MIR /w:1 /r:1 /XD "#recycle" /log:C:\CAHJobs\Backup_To_X.log /np
}
Else {
write-host "F: drive is not mounted" -foreground RED
}
# Write-Host "`r`nAging Files" -Foreground Green
# Write-Host "Zero Days" -Foreground Green
# robocopy "c:\Windows\Temp" c:\~temp . /e /move /r:1 /w:1 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
# robocopy c:\Users\usersname\appData\Local\Microsoft\Windows\InetCache\Content.Outlook\D017l9wk c:\~temp . /e /move /r:1 /w:1 /NFL /NDL /NJH /NJS /nc /ns/ /np | Out-Null
#
# Write-Host "7 Days" -Foreground Green
# robocopy "c:\data\SPAM" c:\~temp /e /move /minage:7 /r:1 /w:1 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
# robocopy "c:\t" c:\~temp . /e /move /minage:7 /r:1 /w:1 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
# robocopy "c:\users\usersname\appdata\local\google\chrome\user Data\default\cache\" c:\~temp . /e /move /minage:7 /r:1 /w:1 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
# robocopy "c:\users\usersname\appdata\local\google\chrome\user Data\default\Application Cache\Cache\" c:\~temp . /e /move /minage:7 /r:1 /w:1 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
# robocopy "C:\Users\usersname\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\H63G57WQ" c:\~temp . /e /move /minage:7 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
#
# Write-Host "20 Days" -Foreground Green
# robocopy "c:\data\t" c:\~temp . /e /move /minage:60 /NFL /NDL /NJH /NJS /nc /ns /np | Out-Null
#
# Write-Host "`r`nRemoving Files" -Foreground Green
# # Remove Files
# remove-Item c:\~temp -Force -Recurse
Write-Host "`r`nComplete" -Foreground Green