Solved

WINDOWS XP PRO SP2 findfiles command

Posted on 2008-10-06
8
1,590 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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
 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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