We need to clean up the files/subfolders from the following folders:
D\Tridion\web\preview
- Daily
D\Tridion\web\Upload
- Daily
C:\temp
- Monthly
//configured in service config
D\Tridion\bin\transactions
- Daily, files older than 5 days
D:\tridion\bin\log
- Weekly (Please suggest)
D:\tridion\log
- Weekly (Please suggest)
Importantly, for some of the folders it is configured in different services. Could you please tell how this can be achieved?
Now, we want to achieve this using a batch job. Please suggest and share your views.
As of now , i have something like (A .bat scheduled)for the folders (sample): Could you please tell if this has any impact or drawbacks, though it is working
@echo off
:: set folder path
set dump_path=D:\Tridion\log\
:: set min age of files and folders to delete
set max_days=5
net stop "Tridion Content Manager Publisher"
:: remove files/subdirectories from %dump_path%
forfiles -p %dump_path% -s -m . -d -%max_days% -c "cmd /c del /q @path"
:: remove empty directories
dir /ad /b /s %dump_path% |sort /r >tmp.tmp for /f "delims=" %%a in (tmp.tmp) do rd "%%a" 2>nul del tmp.tmp
net start "Tridion Content Manager Publisher"
I am not powershell expert, but will try to do somthing taking reference from the script by Chris. Thanks to all of you for your valuable inputs and help.