Windows 10 can automatically clean up disk space using Storage Sense . You can also schedule optimising (defragmentation) of drives automatically.
Go to the search box (shortcut keys: Win key + S) and type in defrag.Then choose Defragment and Optimise Drives.
Alternatively, from File Explorer, choose Manage > Optimise.
You can also access it from Windows Settings (Win key + I) > System > Storage.
From More storage settings, click on Optimise Drives.
A list of drives and partitions will be listed. By default, all of them are optimised weekly but you change their frequency. To manually optimise, select the drive and click on Analyse.
If there is a need to optimise, it will be displayed in the analysis.
Click on Optimise to begin defragmentation. It will run in the background without needing any intervention.
Once completed, the Last run timestamp will change and the latest status of the drive will be displayed.
To change how often they get optimised, click on Change settings.
Then, change the frequency from Weekly (default) to either Daily or Monthly. You can also assign it higher priority rather if the optimisation is skipped three times in a row.
Also, to exclude certain drives and partitions, select Choose and exclude them as needed.
By default, all the drives and partitions are enabled for optimisation but can be excluded from being automatically optimised.