TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   Deleting directory of more than 30 days (http://forums.techarena.in/software-development/1115312.htm)

Mannat 04-02-2009 01:43 PM

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.

Modifier 04-02-2009 01:47 PM

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):

JoeFrat 04-02-2009 01:48 PM

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


Mannat 04-02-2009 01:50 PM

Re: Deleting directory of more than 30 days
 
Quote:

Originally Posted by JoeFrat (Post 4218786)
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 .


All times are GMT +5.5. The time now is 10:34 PM.