Advertisement

02.03.2008 at 08:35PM PST, ID: 23133984
[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!

7.6

VBS to automatically delete FOLDERS

Asked by Jeremy_in_Japan in VB Script

Tags: , ,

I am trying to create a .vbs that deletes FOLDERS. I do not want to use 3rd-party deletion software such as DELENDA or DELOLD. I also do not want to use Powershell. I have searched for this topic on EE but all the scripts concentrate on files within folders. I only need to delete the folders.

I will be executing the script using a scheduled task.

Here is an example of the folder paths (notice there are spaces in the folder name):

d:\BakupDest\Fri 02.01.2008, 12:30
d:\BakupDest\Sun 02.03.2008, 12:30
d:\BakupDest\Mon 02.04.2008, 12:30

I would like a script that deletes the subfolders of d:\BakupDest\ if they are older than thirty days, by last modified date.

The .vbs below works for files (using last created date) but not for FOLDERS. I have tried changing the methods to Folders instead of files or file but I keep getting script errors. I would like the vbs to perform the same function as the script below but for FOLDERS and modified date of the folder.

'-------------- FILEDELETE.vbs --------------------
Option Explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
DeleteFiles fso.GetFolder("c:\PathofMyFolder\")
Sub DeleteFiles(srcFolder)
Dim srcFile
If srcFolder.Files.Count = 0 Then
Exit Sub
End If
For Each srcFile in srcFolder.Files
If DateDiff("d", Now, srcFile.DateCreated) < -30 Then
fso.DeleteFile srcFile, True
End If
Next
End Sub
'-----------------------------------------------

Thank you for your time. Start Free Trial
 
Loading Advertisement...
 
[+][-]02.03.2008 at 08:39PM PST, ID: 20811955

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 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.04.2008 at 05:12AM PST, ID: 20813932

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 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.04.2008 at 05:18AM PST, ID: 20813974

View this solution now by starting your 14-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

Zone: VB Script
Tags: Microsoft, VBS, VBS
Sign Up Now!
Solution Provided By: Jeremy_in_Japan
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02.04.2008 at 05:21AM PST, ID: 20813991

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 14-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628