Solved

FORFILES SYNTAX

Posted on 2006-06-20
6
1,785 Views
Last Modified: 2013-12-28
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

0
Comment
Question by:irishmanjb
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:ECNSSMT
ID: 16943090
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,
0
 

Author Comment

by:irishmanjb
ID: 16944481
Sorry I am getting invalid switch -pf
0
 
LVL 14

Expert Comment

by:ECNSSMT
ID: 16944656
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,
0
Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

 

Author Comment

by:irishmanjb
ID: 16954595
I tried again and keep getting Invalid argument option' -pf\ACT\ACT-offsitebkp\  -m*.zip -d-2  -c"CMD /C del @FILE"
0
 
LVL 14

Accepted Solution

by:
ECNSSMT earned 100 total points
ID: 16976603
if its not because of a typo -pf\ACT\ACT-offsitebkp\  -m*.zip -d-2  -c"CMD /C del @FILE"
instead of -pf:\ACT\ACT-offsitebkp\  -m*.zip -d-2  -c"CMD /C del @FILE"

do a Forfiles ? to see the options presented by this version of Forfiles.  

Regards,
0
 

Expert Comment

by:GENINZ
ID: 32683458
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
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Several part series to implement Internet Explorer 11 Enterprise Mode
Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now