Link to home
Start Free TrialLog in
Avatar of irishmanjb
irishmanjb

asked on

FORFILES SYNTAX

I am trying to remove all zip files from the F:\ACT\ACT-Offsitebkp directory on my server that are greater than 2 days old.  I cannot seem to get this to work on my server.  It works locally when I test it and the directory is c:\ACT\ACT-offsitebkp\

Forfiles -pf:\ACT\ACT-offsitebkp\ *.zip -d-2 -c"CMD /C del @FILE"

I think I am missing something small any help would be appreciated

Thanks

Avatar of ECNSSMT
ECNSSMT

just for laughs, include the path to Forfiles

e.g.

C:\Program Files\someotherfoldernames\Forfiles -pf:\ACT\ACT-offsitebkp\ *.zip -d-2 -c"CMD /C del @FILE"

You didn't state the error you got, so I'm just assuming the basics.

Regards,
Avatar of irishmanjb

ASKER

Sorry I am getting invalid switch -pf
http://www.ss64.com/nt/forfiles.html

have you tried Forfiles -pf:\ACT\ACT-offsitebkp\  -m*.zip -d-2  -c"CMD /C del @FILE"

assuming that F:\ACT\ACT-offsitebkp\ exists

Regards,
I tried again and keep getting Invalid argument option' -pf\ACT\ACT-offsitebkp\  -m*.zip -d-2  -c"CMD /C del @FILE"
ASKER CERTIFIED SOLUTION
Avatar of ECNSSMT
ECNSSMT

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I had the same issue - worked on XP Prof but not on windows 2003 - and found that if I put a space between the switch and variable it worked ok on windows 2003.

EG: -
-p f:\ACT\ACT-offsitebkp\  -m *.zip -d -2  -c "CMD /C del @FILE"

cheers