Advertisement

04.05.2007 at 01:03PM PDT, ID: 22495164
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Batch file:  Delete folders exactly 4 days old

Asked by BJTurner in Windows Batch Scripting, MS DOS, Windows XP Operating System

Tags: , , , ,

I've got a batch script and it needs to delete archive folders that are older than 4 days.  Here are the steps the batch files does (extreme pseudocode):

Delete archive folders older than 4 days
Create archive folder for today ("04_05_2007")
Run DB macro to extract files
Send files to new location
Copy files to newly created archive folder ("04_05_2007")
Exit

I'm fairly new to batch scripting and am re-using someone else's code to try to learn how to do this.  Here is how he is getting the date for today and creating the directory:

SET CurrDay=%DATE:~7,2%&::
SET CurrMonth=%DATE:~4,2%&::
SET CurrYear=%DATE:~10,4%&::
SET CurrDate=%CurrMonth%_%CurrDay%_%CurrYear%
SET archivedir="C:\Corp\Mrktg\Production\CARAT Extract\Archive"

CD /D %archivedir%
MKDIR %CurrDate%

Is there a way to build off of this existing code?  Some way to say %CurrDate%-4 or %CurrDay-4% (which does not work by the way) and then delete that specific directory that is 4 days old?  This is a process that will run everyday so during each run there should only be one directory that is being deleted, the one exactly 4 days old.

I appreciate any help in this area.  I've looked around and seen some batch solutions for things like CALL: SUBTRACTDAYS but don't see how that can be tailored to fit the current way I'm getting the date.Start Free Trial
 
Loading Advertisement...
 
[+][-]04.05.2007 at 01:43PM PDT, ID: 18860876

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Windows Batch Scripting, MS DOS, Windows XP Operating System
Tags: batch, delete, file, old, folders
Sign Up Now!
Solution Provided By: SteveGTR
Participating Experts: 3
Solution Grade: A
 
 
[+][-]04.05.2007 at 01:51PM PDT, ID: 18860942

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]04.05.2007 at 02:06PM PDT, ID: 18861044

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2007 at 02:11PM PDT, ID: 18861082

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.05.2007 at 02:36PM PDT, ID: 18861229

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.09.2007 at 08:37AM PDT, ID: 18876322

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32