Solved

Batch File

Posted on 2001-09-05
4
334 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 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