Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-02-2009
Member
 
Join Date: Dec 2008
Posts: 33
Deleting directory of more than 30 days

I am looking for a DOS command to delete the subdirectory of a directory XX A with a creation date greater than 30 days from the date of the day. For a project of video monitoring, which records can not exceed 30 days of storage.

Note: Be indulgent please because I've never done programming. thank you for your responses.
Reply With Quote
  #2  
Old 04-02-2009
Member
 
Join Date: Jan 2008
Posts: 1,515
Re: Deleting directory of more than 30 days

Hello,

Dos it not so much flexible instead you can vbscript to do it.here i have this code .I confirm there is no DOS command unit that makes the job. Batch is a real gas plant. Is better to move to another language (vbscript to test but something about it should work):
Reply With Quote
  #3  
Old 04-02-2009
Member
 
Join Date: May 2008
Posts: 115
Re: Deleting directory of more than 30 days

Hi modifier is right here the code for your requirement in vb script hope this will help you

Code:
Select All 
Dim objFso, objFolder, objSubFolder 
Dim strPath 
Dim diffDate 
Dim arrSubFolder() 
Dim i 

strPath = "c:\tmp\toto" 
nbDays = 30 

Set objFso = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFso.GetFolder(strPath) 
Set objSubFolder = objFolder.SubFolders 

For Each folder in objSubFolder 
diffDate = DateDiff("d",folder.DateCreated,Now) 
if diffDate > nbDays then 
ReDim preserve arrSubFolder(i) 
arrSubFolder(i) = folder.Name 
i = i + 1 
end if 
Next 

For Each folder in arrSubFolder 
objFSO.DeleteFolder(strPath & "\" & folder) 
Next 

set objFso = nothing 
set objFolder = nothing 
set objSubFolder = nothing
Reply With Quote
  #4  
Old 04-02-2009
Member
 
Join Date: Dec 2008
Posts: 33
Re: Deleting directory of more than 30 days

Quote:
Originally Posted by JoeFrat View Post
Hi modifier is right here the code for your requirement in vb script hope this will help you

Code:
Select All 
Dim objFso, objFolder, objSubFolder 
Dim strPath 
Dim diffDate 
Dim arrSubFolder() 
Dim i 

strPath = "c:\tmp\toto" 
nbDays = 30 

Set objFso = CreateObject("Scripting.FileSystemObject") 
Set objFolder = objFso.GetFolder(strPath) 
Set objSubFolder = objFolder.SubFolders 

For Each folder in objSubFolder 
diffDate = DateDiff("d",folder.DateCreated,Now) 
if diffDate > nbDays then 
ReDim preserve arrSubFolder(i) 
arrSubFolder(i) = folder.Name 
i = i + 1 
end if 
Next 

For Each folder in arrSubFolder 
objFSO.DeleteFolder(strPath & "\" & folder) 
Next 

set objFso = nothing 
set objFolder = nothing 
set objSubFolder = nothing


In theory they will contain only files (recordings). Thank you for the code, I will show it to my colleague. And it will test. Ah I did not specify. It should also be removed empty directories .
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Deleting directory of more than 30 days"
Thread Thread Starter Forum Replies Last Post
Calendar days vs work days Boerseun Microsoft Project 4 02-07-2014 10:28 PM
Converting work days to calendar days TheTurner Microsoft Project 12 02-07-2014 10:15 PM
Script for deleting folders + content in root of D:\ after # days lca1630 Windows Server Help 6 28-03-2012 08:50 PM
Changing Calendar to count all days and not only BUSINESS days M Moreno Microsoft Project 3 12-01-2011 05:05 AM
find period in days / hours excluding weekdays between two days? Segvoia Software Development 3 19-06-2009 11:17 AM


All times are GMT +5.5. The time now is 11:49 AM.