Solved

WINDOWS XP PRO SP2 findfiles command

Posted on 2008-10-06
8
1,587 Views
Last Modified: 2008-10-11
When I run the following code

Forfiles -p. -s -m*.* -d-1 -c "Cmd /C del @FILE"

I get an error

can't execute (error 2)

I am trying to create a batch file that at startup will delete all files older than today in 2 directories.  This code, as I test, only works on the current directory

Any thoughts are greatly appreciated.
0
Comment
Question by:bschiel
  • 4
  • 4
8 Comments
 

Expert Comment

by:corstiaan_haaij
ID: 22653600
You can build the following batch job:

forfiles /p "drive:\directory" /s /m *.* /d -1 /c "cmd /c del @file"
forfiles /p "drive:\other directory" /s /m *.* /d -1 /c "cmd /c del @file"
0
 

Author Comment

by:bschiel
ID: 22653710
That is the eventual goal, but I am trying to find out why the first code is not working
0
 

Expert Comment

by:corstiaan_haaij
ID: 22654153
you have to specify a directory after the /p and add a space after each parameter
0
 

Author Comment

by:bschiel
ID: 22654198
/p . defines the directory as the CURRENT directory

When I add spacing I get
C:\>Forfiles -p . -s -m *.* -d -1 -c "Cmd /C del @FILE"
FORFILES v 1.1 - by Emmanuel Boersma - 4/98


Syntax : FORFILES [-pPath] [-mSearch Mask] [-ccommand] [-dDDMMYY] [-s]

 -pPath             Path where to start searching
 -mSearch Mask      Search files according to <Search Mask>
 -cCommand          Command to execute on each file(s)
 -d[+|-][DDMMYY|DD] Select files with date >= or <=DDMMYY (UTC)
                    or files having date >= or <= (current date - DD days)
 -s                 Recurse directories
 -v                 Verbose mode

The following variables can be used in Command :
 @FILE, @PATH, @RELPATH, @ISDIR, @FSIZE, @FDATE, @FTIME


Default : <Directory : .> <Search Mask : *.*>  <Command : "CMD /C Echo @FILE">
Examples :
FORFILES -pc:\ -s -m*.BAT -c"CMD /C Echo @FILE is a batch file"
FORFILES -pc:\ -s -m*.* -c"CMD /C if @ISDIR==TRUE echo @FILE is a directory"
FORFILES -pc:\ -s -m*.* -d-100 -c"CMD /C Echo @FILE : date >= 100 days"
FORFILES -pc:\ -s -m*.* -d-010193 -c"CMD /C Echo @FILE is quite old!"
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Expert Comment

by:corstiaan_haaij
ID: 22654336
Which error will be shown?
When i run this batch no error will appear!
0
 

Author Comment

by:bschiel
ID: 22654392
When I run the original code I get what I originally posted.

When I run as you suggested, I get what I just posted.  Not sure what additional info you want
0
 

Accepted Solution

by:
bschiel earned 0 total points
ID: 22654724
Solved my own problem.....

I was using an older version of FORFILES that did not work correctly with XP.  Pulled a newer version from my 2K3 server and it works as it supposed too.
0
 

Expert Comment

by:corstiaan_haaij
ID: 22654742
okay great
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

22 Experts available now in Live!

Get 1:1 Help Now