Open Powershell in admin mode
Copy the entire script
Note: You must have powershell 3.0 to avail Start-Transcript cmdlet.
Ensure that in your script, you have the proper database context mentioned.
If you have a requirement to send email to recipients with attachment, can use the script.
Using Powershell, Cleanup Older than 30 days of Files & Folder through SQL Job