Looking for a script that will delete folders or files.

filmoore54

New Member
Joined
Sep 8, 2021
Messages
2
Achievements 1
No badges yet
Problem Solver
Reliable Fixer
Answer Authority
Looking for a script that will delete daily backup folders or files. Id like to use task scheduler to run it on a daily basis...
 

Solution
You would need to be a lot more specific.

*POWERSHELL*
Remove-Item -Path 'C:\Somepath' -Recurse
Would be enough to delete the directory C:\Somepath. If it needs to look at MAC times and delete based on that you could do some some simple filtering with Where-Object.

Neemobeer

Windows Forum Team
Staff member
Joined
Jul 4, 2015
Messages
8,998
Achievements 43
Problem Solver Reliable Fixer Answer Authority WindowsForum Expert Question Guide
News Scanner
Update Watcher
Patch Tuesday Regular
You would need to be a lot more specific.

*POWERSHELL*
Remove-Item -Path 'C:\Somepath' -Recurse
Would be enough to delete the directory C:\Somepath. If it needs to look at MAC times and delete based on that you could do some some simple filtering with Where-Object.
 

Solution

filmoore54

New Member
Joined
Sep 8, 2021
Messages
2
Achievements 1
No badges yet
Problem Solver
Reliable Fixer
Answer Authority
If I understand it correctly, then the following statements would do what I am attempting...I just have to figure out the variables in order to do it on a daily basis and then create a task to run it...

Folder
Remove-Item -Path 'B:\DBBackups\2021-08-30_22-00-02' -Recurse

File
Remove-Item -Path 'F:\Backup\FullBackup09072021' -Recurse
 

Back
Top