Windows scripted FORFILES / del function (on Server 2012)

I'm using a script that I got from here which automates a mySQL dump of all databases, .zip's them, and then deletes all the .zip files older that what you specify:
http://www.redolive.com/utah-web-designers-blog/automated-mysql-backup-for-windows/

The site says the script is tested on Server 2008.  I'm running this on Server 2012.


The script is working except for the delete the older .zip files part, which is this line of the script:


echo “Deleting zip files older than x days now”
Forfiles -p %backupfldr% -s -m *.* -d -%retaindays% -c “cmd /c del /q @path”

Open in new window



If I run the script from the command line, at this part it errors with:

ERROR: Invalid argument/option - '/q'.
Type "FORFILES /?" for usage.


If I remove the /q part from the script just to see what happens, it then complains about a different part of the command:

ERROR: Invalid argument/option - '@path'.
Type "FORFILES /?" for usage.



This is the only script I found that can automate MySQL backups on WIndows fully (with archiving, deleted .sql files, and then deleting older .zip files).

I'm guessing something must be different in Server 2012.  

Any idea what should be fixed for that line above?



Thank you
LVL 1
VasAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Have a really, really close look at the command you're trying to run, as it is posted here, and as it is in your editor.
You'll notice that the quotes around the command are "prettified". Delete all these "curly" quotes and replace them with proper straight ones, then try again.
“cmd /c del /q @path” (incorrect double quotes for scripting)
"cmd /c del /q @path" (correct double quotes for scripting)

Open in new window

VasAuthor Commented:
I think it's just in this browser that it pasted that way.  The script has the correct quotes and also just in case I re-typed the straight quotes to be sure and still getting the same error:


7-27-2015-10-19-36-AM.jpg
oBdACommented:
The screenshot helped; the issue is probably the definition of the %backupfldr% variable: remove the trailing backslash in "C:\MySQLDumps\".

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VasAuthor Commented:
That fixed it thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.