Any Batch File Experts?

I would like to write a batch file in order to delete some backup files and directories according to their age. The directories change names every day with the date appended to the name. The batch file would be run by Comodo Backup after the backup is completed. If someone could help me out in this I would appreciate it. I use XP Home 32bit.


It would be very easy if the files or folders to delete had always the same names. However they will change with time…

Even if this were possible with a batch script, it will likely be easier with another full programming language (no kidding, it shouldn’t be hard). :slight_smile:

I used to write DOS batch files, but if the name is going to change each time, not much a simple batch program can do.

Thanks for your replies guys

I guess I will have to research the best way to do this.


@echo off
echo wscript.echo date-1>tmp.vbs
for /f %%a in (‘cscript tmp.vbs //Nologo’) do set “yesterday=%%a”
for /f “tokens=1-3 delims=/” %%a in (“%yesterday%”) do (
set “mm=%%a”
set “dd=%%b”
set “yy=%%c”
if “%mm:~1,1%”==“” set mm=0%mm%
if “%dd:~1,1%”==“” set dd=0%dd%
echo %mm%%dd%%yy:~-2%& DEL tmp.vbs

this batch file generates %yesterday% in MMDDYY format. if %today% is 022009, this batch outputs 021909. it can be easily modified to kick out any previous date that you want.



That looks like what I need. I will test is out.

Welcome to the Comodo forum.


You must be a good batch file expert…I’m just staring blankly at the jumble of characters. :slight_smile:

All I know how to do is close and execute processes, and stop and start services. :-\

But that’s all I need to know for now. :slight_smile: