Frage

I cant get FORFILES to work for me. I run a .bat that backs up a few databases I have each day using this one example below.

COPY "X:\W Attendenance\C Crew Attendance\Attendance Control DB v4.xx.accdb" "X:\Supervisors Log\Backups\Attendance Bak\bak_%currdate%_Attendance Control DB v4.xx.accdb"

Then after running my backups I wanted to delete the old files that were older than five days by using the below example.

FORFILES /p "X:\Supervisors Log\Backups\Attendance Bak\" /d -5 /c "cmd /c del @path "

But what happens is it creates the backups but never deletes the old ones. What am I doing wrong?

Ken it still seems to not work. I changed the @file to @path and ran and I still have my backups. I also had another question, can I limit the delete to just files starting in bak_ ? and can I delete the file by its name because every backup starts with bak_ then the date mm-dd-yyyy_ then name of the file...

War es hilfreich?

Lösung 2

On a side note that only is able to delete the File but Sometimes I needed to delete a folder and everything in it so I use:

FORFILES /P "H:\BACKUPS\bk_Operator_Rate_Program" /d -10 /c "cmd /c IF @isdir == TRUE rd /S /Q @path"

Andere Tipps

This fixed it... Thanks for your help and links!

forfiles -p "X:\Supervisors Log\Backups\Attendance Bak" -s -m *.* -d -1 -c "cmd /c del @path"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top