Results 1 to 4 of 4

Thread: Deleting directory of more than 30 days

  1. #1
    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.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

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

  3. #3
    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

  4. #4
    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 .

Similar Threads

  1. Calendar days vs work days
    By Boerseun in forum Microsoft Project
    Replies: 4
    Last Post: 02-07-2014, 10:28 PM
  2. Converting work days to calendar days
    By TheTurner in forum Microsoft Project
    Replies: 12
    Last Post: 02-07-2014, 10:15 PM
  3. Replies: 6
    Last Post: 28-03-2012, 08:50 PM
  4. Replies: 3
    Last Post: 12-01-2011, 05:05 AM
  5. find period in days / hours excluding weekdays between two days?
    By Segvoia in forum Software Development
    Replies: 3
    Last Post: 19-06-2009, 11:17 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,302,707.04315 seconds with 16 queries