Solved

Batch File

Posted on 2001-09-05
4
339 Views
Last Modified: 2013-12-03
i need a batch file that I can use that deletes files in a specific directory according to their date.

For exampple i need to delete all files older that one month that end in txt.  I'll increase the points if anyone actually manages to do this in a simple dos type batch file.
0
Comment
Question by:leighmurray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 8

Expert Comment

by:ViRoy
ID: 6459360
that would require building a batch file that can somehow determine specific sections of a dir
i dont even think its possible in batch

now qbasic could be used to do this
do a "dir /OD > file.txt"
then have a subroutine parse the info for the dates you are looking for.
0
 
LVL 1

Accepted Solution

by:
hide_in earned 100 total points
ID: 6459401
OK, if you want to delete all files (*.txt) in one folder,y
you can do as following:
//-----------------------------------
suppose the path is "c:\test"

WIN32_FIND_DATA FindFileData;
HANDLE hFind = NULL;
HANDLE hFile = NULL;

char szPath[MAX_PATH + 1] = "";
strncpy(szPath, "c:\\test\\*.txt", sizeof(szPath) - 1);
 
hFind = FindFirstFile(szPath, &FindFileData);
if (INVALID_HANDLE_VALUE  != hFind)
{
  while (true)
  {
     if ('\0' != *FindFileData.cFileName)
     {
        // then, you can get the file in the c:\test dir,
        // Add the code to get the file attribute,
       // and judge the time of it if older than you want
     }
     memset(&FindFileData, 0 , sizeof(FindFileData));
    if (TRUE != FindNextFile(hFind, &FindFileData))
       break;
  }
  FindClose(hFind);
}

can you understand ?
0
 
LVL 6

Expert Comment

by:Triskelion
ID: 6466186
Here are some utilities that can do what you want.

Not batch files, though.
Delete Enhanced
http://users.aol.com/pasacaca/delen/delen32.zip
http://users.aol.com/pasacaca/delen/delen16.zip
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 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