using FORFILES in batch to delete tmp and bak files older than a week
If you're running this from the console, it should work. If you're saving this to a .bat file, then the format for variables is a little different. You have to use two percentage signs to signify a variable. So, your command would then become...
for %%G in (.tmp, .bak) do forfiles -p "C:\test\cad projects" -s -m *%%G -d -7 -c "cmd /c del @path"
Microsoft's KB75634 article explains why this is.
If there are no characters between the two percent signs, one percent sign is stripped off and the other will remain. This is why a FOR command that echos the name of each file with a .COM extension would be
FOR %V IN (*.COM) DO ECHO %V
but if the same command is placed in a batch file, the following is required:
FOR %%V IN (*.COM) DO ECHO %%V