The techie in me RSS 2.0
 Friday, November 26, 2010

 

I don't think we can ever say good by to our good old MS-DOS. My first intimate interaction with Micro Computer(the original name of PC ) was through MS-DOS. Now in the advanced age of computer still I am using DOS, this time as part of one the build scripts. Our continuous integration creates an installer every night(early morning to be exact – this is a cheat, I'll describe it later). We want to keep them for 2 weeks and delete afterwards. Now to do this I can create a simple .net console app, which will be more efficient in error handling etc. But I like to do it in the good old way :).

Found a command line utility –ForFiles- comes with WinXP command line.

(If you don't have installed by default – in most of the case no- you can download it from the MS FTP server. You may want to place it to C:\WINDOWS\system32 or update the PATH variable accordingly)

forfiles -p "C:\SearchFolder" -s -m*.msi -d-14 -c "cmd /c del @path"

-p : path to search for
-s : include subdirectories
-m : search mask (*.msi files here)
-d : files older than days (14 in my case), you can use dates instead
-c : the command to execute on the files

also checkout the help for 'forfiles'. If you have forgotten how to do it, its forfiles/?... uh it doesn't work ? simply type forfiles :)

 

The following variables can be used in Command : (@path is already used in the above example)
@FILE, @FNAME_WITHOUT_EXT, @EXT, @PATH, @RELPATH, @ISDIR, @FSIZE, @FDATE, @FTIME

 

hope this helps...

 

edit

 

found a nice website with WinXP command lines

Friday, November 26, 2010 6:58:00 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Coding | Everything | Legacy
Comments are closed.
About me
Name : Rujith Anand Send mail to the author(s)
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogs I read
Disclaimer

Disclaimer
Postings are provided as is with no warranties, and confer no rights. Opinions expressed here are my own delusions; my employers at best shake their heads and sigh, at worst repudiate the content with extreme prejudice, whenever it manages to appear on their radar.

© Copyright 2012
Rujith Anand

Statistics
Advertisement
All Content © 2012, Rujith Anand