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.
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):
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
Re: Deleting directory of more than 30 days
Quote:
Originally Posted by
JoeFrat
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 .