- Script below can be used to delete the files which are older then 2 days from All Available Drives On Servers:\AnyDirectory.
- If you want to filter files with some particular extension please add the following handle to the script :
- /m (searchmask) Searches files according to the specified search mask. The default search mask is *.\*.
- More information about parameters and variables available can be found here
@ECHO off
Rem===================================================================================================================
Rem AUTHOR: SHIVAM KUMAR | https://www.linkedin.com/in/shivamkumars
Rem VERSION: 1.0
Rem DESCRIPTION: Script to delete the files which are older then 2 days from "All_Available_Drives_On_Servers:\AnyDirectory" directory
Rem How to use: Select the servers from hpsa and right click and run script,no user input is required.
Rem Disclaimer: The script has to be run on proper timings after the backup or what ever patching activity else you might loose data.
Rem===================================================================================================================
for /F "skip=1" %%Y in ('wmic Logicaldisk get caption') do (
for /F %%G in ("%%Y") do (
forfiles.exe /p %%G\AnyDirectory\ /m * /d -2 /c "cmd /c if @isdir==TRUE rmdir /Q @path /S"
)
)
EXIT /B 0
Comments
Post a Comment
Note:Please be gentle while commenting and avoid spamming as comment are anyways moderated thank you.