27 April 2013

Script to delete older files at a network path

Here's a batch script for deleting files older than 90 days. Because the files are on a UNC share, the pushd and popd commands need to be used to make Windows happy:

@echo off
rem Delete disk backups older than 90 days
echo Deleting old disk backups...
pushd \\192.168.10.250\Backups\
forfiles -m *.bak -d -90 -c "cmd /c del @path"
popd
echo Complete.

2 comments: