Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with forfiles command

Status
Not open for further replies.
Feb 4, 2011
53
CA
I have a network drive that I copy SQL backup files to. The SQL version is an express version so I have to use a batch script to create the backup locally and then copy the files to the network drive. Any how, I am trying to use forfiles to remove any data older than 2 days so that the folder doesn't fill up. My code is as follows:
Code:
forfiles /p "Z:\" /m *.BAK /d -2 /c "cmd /c DEL @file" >> "c:\batch files\script.log" 2>&1

However I get an error:
ERROR: Invalid argument/option - '@file '.
Type "FORFILES /?" for usage.

I have tested this code on my Windows 7 PC and it works fine. However on 2008 Server it is not. I tested using a local directory, could working with a mapped network drive be the issue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top