Delete Aged Files & Folders from Subfolders

Hi,
I have the following script to delete files and folders older than 7 days. It work but I need to be able to go through subfolders as well:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\FTPRoot_External")
For Each file in objFolder.Files
If DateDiff("d", file.DateLastModified, Now) > 7 Then
objFSO.DeleteFile(file)
End If
Next
For Each folder in objFolder.SubFolders
If DateDiff("d", file.DateLastModified, Now) > 7 Then
objFSO.DeleteFolder(folder)
End If
Next
Any suggestions?
Thanks.

Here is an example I coded sometime ago with a recursive sub. You can modify this for your needs:
Option
Explicit
Dim strFolder, objFSO, objFOlder
' Specify main folder.
strFolder = "c:\scripts"
' Retrieve folder object.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(strFolder)
' Enumerate files.
Call GetFiles(objFolder)
Sub GetFiles(ByVal objParent)
    ' Enumerate files in folder.
    Dim objFile, objChild
    For Each objFile
In objParent.Files
        Wscript.Echo objFile.Path &
"," & objFile.DateLastModified
    Next
    ' Recurse through nested folders.
    For Each objChild
In objParent.SubFolders
        Call GetFiles(objChild)
    Next
End Sub
Richard Mueller - MVP Directory Services

Similar Messages

  • In idvd 6.0.1 how do I delete/remove files/folders from the media pane?

    for some reason some of the folders in my photos media pane are now empty? how do I get rid of those folders?

    iDVD is a tool for creating videoDVDs from some media (stills, video, music)
    it is NOT the Finder, which is the Mac's "app" to handle files&folders
    and it is NOT the "creator" of stills (iPhoto), videos (iMovie) or music (iTunes)
    spend some time reading here: http://www.apple.com/ilife/tutorials/

  • Can I remove backuped files/folders from Azure Backup storage without un-registor the servers ?

    Can I remove backuped files/folders from Azure Backup storage without un-registor the servers ?
    I want to remove some backuped files/folders to compact Azure Backup Storage and to save the cost of Azure Backup.
    Scenario 1: remove tempolary files from Azure Backup Storage.
    Scenario 2: remove no-recovery files from Azure Backup Storage.
    Scenario 3: move the files from backup target folder to other storage's folder.
    Now, To remove backup files/folder from Azure Backup storage, I seems to need un-register the servers, and register the server.
    Regards,
    Yoshihiro Kawabata

    Thank you Giri, for quick reply.
    I want to save the Azure Backup storage cost, now.
    I don't want to pay the Azure Backup storage cost for no-restore-need files until the backup point gets aged.
    and I don't want to remove / re-backup the restore need files by un-register/register operation.
    I feedback this issue to feedback.azure.com.
    "Remove files/folders from Backup"
    http://feedback.azure.com/forums/258995-azure-backup-and-scdpm/suggestions/7421659-remove-files-folders-from-backup
    Regards,
    Yoshihiro Kawabata

  • Can I delete the files/folders in 'Apple Computer\MobileSync\Backup'?

    Hi!
    I have just tried to backup and update my iphone to iOS 5.1. The backup seems to have worked but when it came to restoring the iphone, I think the hard disk ran out of space and so it failed. I saw this and so I freed up around 3Gb of disk space and I tried it again. It again failed. Again I noticed that there was no space left on the hard disk. I assumed that to continue the restore it probably won't need that much more space (as it had already done most of the work) so I freed up a few more Gb.
    Again it failed. When it fails, itunes leaves the partially restored elements on my hard disk meaning that my 'Apple Computer' folder is now 28Gb!! I cannot afford to delete anything else from the hard disk. I am using a PC by the way. I have noticed that in the folder 'Apple Computer\MobileSync\Backup' has 5 folders in it which is the same amount that I tried to restore the iphone (before the last restore attempt there were 4 folders). These folders amount to 20Gb. From this I am assuming that the actual backup that I made is infact in 'Apple Computer\iTunes\Mobile Backups'.
    Can I delete the folders in 'MobileSync\Backup'? This would free up 20Gb of disk space giving me enough to properly restore (in theory!).
    Thanks for your time!!
    Nick

    your advice worked for me and saved me what ever evil lurked behind my thought to just delete the backup and get back my very lmited space on my 250GB Mackbook Pro using daisydisk pro https://itunes.apple.com/us/app/daisydisk/id411643860?mt=12
    Why DaisyDisk?
    DaisyDisk remains the tool of choice for film makers (including companies like Pixar), digital artists, IT professionals and hundreds of thousands of Mac users worldwide when it comes to disk space management. Constantly improving since its initial introduction, the app easily blows away competition in terms of speed, efficiency and user experience.
    @wjostenMar 27, 2012 4:03 AM Re: Can I delete the files/folders in 'Apple Computer\MobileSync\Backup'?
    Re: Can I delete the files/folders in 'Apple Computer\MobileSync\Backup'?in response to nickcrowney
    Delete iOS backups this way: iTunes>Preferences>Devices...select the backup/backups...hit delete. Do not mess with your backup folder.

  • Application to remove junk files/folders from Noki...

    Dear Frineds,
    Can you please suggest a application to remove junk files/folders from my Nokia E63?
    Narottam Das
    Kolkata, India

    Dear Frineds,
    Can you please suggest a application to remove junk files/folders from my Nokia E63?
    Narottam Das
    Kolkata, India

  • Transferring personal files/folders from Dell PC to an iPad2 or iPad3?

    Is it possible to load some personal files/folders from my existing Dell desktop to an iPad2 or 3? Nothing too big, just some MS Office Word and Excel docs, pictures, and some PDF docs. I'm trying to figure out if I can/should replace my current PC with an iPad, just for personal use, not work. I'm so used to a USB port and flash drive to copy and move stuff and I understand the iPad doesn't have that capability, so I am kind of lost here. I have an iPhone 4 so am a little familiar with the apple navigation. Any suggestions/recommendations from experienced iPad users is appreciated!!

    My formatting stays intact. Docs to Go talks about their 'intact technology' that keeps tabs, etc, where they were.
    Obviously any mobile app is far less robust than a bonafide word processing program, but minor formatting, bold, italics, underline, tabs, etc seem to transfer quite well.
    I don't have any complicated excel spread sheets so I don't have any experience with their functionality.
    I've found the docs to to go be virtually seamless. That said, I've never used them with 'fancy formatting', so that may be trial and error.

  • Why cant i delete icloud contact folders from outlook

    why cant i delete icloud contact folders from outlook

    How are you trying to delete them, and what error messages are you seeing when you do?

  • Deleteing files/folders from network drive

    I have a USB drive connected in to my Airport Extreme and I have conifgured user level access accounts for this. The four the iMac G4, iMac G5, iBook and Powerbook are all able to copy and delete files/folders with no problems. My Windows Vista machine is able to copy files/folders but I am only able to delete folders when they contain no files or sub-folders - sadly I do not have access to the full message but it is related to not having the correct permissions.
    The USB drive is Mac OS X Extended format as a Fat 32 format drive did not appear on the network (this was before the recent Airport update though).
    Has anyone else encountered this problem and if so - do you know of a way around it?

    Guess it's just me
    Any ideas?

  • Delete created then deleted icloud email folders from thunderbird emial program

    I have different folders and subfolders in my iCloud email account over a long period of time. I can go into years of history of why but I don’t think that is neither important nor relevant. Suffice to say I installed my iCloud acct on thunderbird email and the folders and subfolders always automatically installed below main inbox. As I changed my folders and subfolders due to way too many and tried to reduce all these folders it worked fine in my apple iCloud emails accounts. In tbird, not so much. The folders I deleted after moving the emails that were there to different new folders tbird iCloud autoed the new folders and left the old that will not delete, change, move nor rename. I get the message that the folder is NONEXISTENT from tbird from iCloud each time I try. I just don’t seem to be able to find a solution to resolve this problem and maybe there is not one. If I have to delete the iCloud acct from tbird, so be it. I guess I can move any and all emails to some other non iCloud acct, delete iCloud, reinstall iCloud and hope all previous emails are not lost in the process. Also, one last question here I have always forgotten to ask. I often leave my iCloud email address when I enroll in something. Sometimes (maybe all the time) I get 2 copies of the email sent to the iCloud acct. is there a reason for double copies I do not know about?

    I have different folders and subfolders in my iCloud email account over a long period of time. I can go into years of history of why but I don’t think that is neither important nor relevant. Suffice to say I installed my iCloud acct on thunderbird email and the folders and subfolders always automatically installed below main inbox. As I changed my folders and subfolders due to way too many and tried to reduce all these folders it worked fine in my apple iCloud emails accounts. In tbird, not so much. The folders I deleted after moving the emails that were there to different new folders tbird iCloud autoed the new folders and left the old that will not delete, change, move nor rename. I get the message that the folder is NONEXISTENT from tbird from iCloud each time I try. I just don’t seem to be able to find a solution to resolve this problem and maybe there is not one. If I have to delete the iCloud acct from tbird, so be it. I guess I can move any and all emails to some other non iCloud acct, delete iCloud, reinstall iCloud and hope all previous emails are not lost in the process. Also, one last question here I have always forgotten to ask. I often leave my iCloud email address when I enroll in something. Sometimes (maybe all the time) I get 2 copies of the email sent to the iCloud acct. is there a reason for double copies I do not know about?

  • Is it safe to delete preview files/folders?

    I noticed I have 30gb or more of folders in a folder called preview files.  These seem to be the product of rendering and look like a waste of space - what happens if i delete the whole lot for projects i no longer work on?  would removing these and the CFA and PEAK files damage the ability to work on the file at a later stage?  I could use the extra space!
    j

    First of all, there is a difference between preview files and Media Cache files.
    Preview files are those, which are created when you render the timeline. By default they are .mpeg and .xmp. If you delete them via Sequence -> Delete Render Files, .mpeg files, which represent the current state of your timeline, will be deleted, whereas the rest .mpeg files, which represent older state of your timeline, and all .xmp ones remain.
    If you delete them manually, i.e. without going to Sequence -> Delete Render Files, you will be asked about some missing media on that project re-launch.
    Media Cache files, some of which are .pek and .cfa, are created when you import assets into a project. You can check the Media Cache files location via Preferences -> Media.
    Deleting all files from both Media Cache and Media Cache Files folders is safe: PrPro will rebuild Media Cache Database from scratch on restart. Moreover, deleting all files from both Media Cache and Media Cache Files manually sometimes helps fixing Dynamic Link or Importer Generic Error issues.

  • Cannot restore some files/folders from Time Machine Backup

    When I try and restore files or folders from my Pictures folder, which is a sub folder of my user I get the message "The operation can’t be completed because you don’t have permission to access xxxx". As far as I can tell this has only just started to happen because I've recovered stuff from the folder since I bought the machine in July. Yesterday I deleted an old Time Machine backup folder from the Time Machine disc. This caused empty trash to go berserk - the "files to delete" count went negative and I had to stop/restart the empty trash command about 20 times before it sorted itself out. Maybe this has screwed some permissions somewhere? I have run disc utility and repaied permissions on my hard drive and verified the TM drive. Still no joy. The permissions for Pictures look OK. Anyone any ideas?

    Yesterday I deleted an old Time Machine backup folder from the Time Machine disc. This caused empty trash to go berserk - the "files to delete" count went negative
    Probably you corrupted your Time Machine Backup by manually deleting older backups- that is dangerous.
    See Pondni's advice on how to fix it - Time Machine trouble Shooting
    I hope that helps
    Léonie

  • Can I delete song file directly from iTunes?

    Currently if I want to delete any songs from my HDD I have to:
    ○ Right click th song in iTunes .
    ○ Click "Show in Windows Eplorer".
    ○ Delete the file.
    ○ Delete song in iTunes library.
    ◙ And repeat it all if there are more than one song I need to delete.
    Is there any way to delete files from iTunes directly?

    Stuwawah wrote:
    You can but in order to be able to do it directly from iTunes, the song/songs need to be store in the "iTunes folder" in your media directory or the Default folder to chose Under:
    ** Preferences -> Advanced -> Itunes Media folder location
    That is not accurate.
    I do not keep my media in the iTunes folder because I personally cannot stand the way iTunes manages the folders.
    I am able to delete media from my computer via iTunes by simply selecting delete and then selecting the option to let iTunes remove it from the drive.

  • Permanently exclude certain files & folders from backup

    I see in the discussions where you can delete certain files or folders from TM backups. Does this exclude those files from future backups as well? Or do you have to go back into TM every time and delete them?
    Thanks.

    Barb2008 wrote:
    I see in the discussions where you can delete certain files or folders from TM backups. Does this exclude those files from future backups as well?
    No. But you can add files/folders to the TM exclusion list in system preferences->TM->options. that will stop future backups of those files/folders.

  • To delete perticular file (*.enc) from folder inside folder  n  so On...

    i want to delete file (*.enc) from following structure.
    d:/ test / myfile.enc
    d:/ test / ex / myfile.enc
    d:/ test / ex / eng /myfile.enc
    d:/ test / ex / Anymyfile.enc
    how to delete it from such type of structure only (*.enc) file OK
    reply me
    not who earlier reply me ( he must be shame to answer)

    > not who earlier reply me ( he must be shame to answer)
    What kind of remark is this?
    The one who replied to you, posted a link to a thread similar to your question, there is even some code in that thread how to recursively do what you want to do. In the other thread he told you not to cross-post your question.

  • Not able to copying files/folders from one Document Library to another Document Library using Open with Browser functionality

    Hi All, 
    We have SharePoint Production server 2013 where users are complaining that they are not able to copy or move files from one document library to another document library using “Open with Explorer” functionality.
    We tried to activate publishing features on production server but it did not work. We users reported following errors:  
    Copying files from one document library to another document library:
    Tried to map the document libraries and still not get the error to copy files: 
    In our UAT environment we are able to copy and move folders from using “Open with Explorer” though.
    We have tried to simulate in the UAT environment but could not reproduce the production environment.  
    Any pointers about this issue would be highly appertained.
    Thanks in advance
    Regards,
    Aroh  
    Aroh Shukla

    Hi John and all,
    One the newly created web applications that we created few days back and navigated to document library, clicked on “Open with Explorer”, we get this error.
    We're having a problem opening this location in file explorer. Add this website to your trusted and try again.
    We added to the trusted site in Internet Explorer for this web application, cleared the cache and open the site with same document library but still get the same above error.
    However, another existing web application (In same the Farm) that we are troubleshooting at the moment, we are able click on “Open with Explorer”,  login in credentials opens and we entered the details we are able to open the document
    library and tried to follow these steps:
    From Windows Explorer (using with Open with Explorer), tried to copy or move a files to
    source document library.
    From Windows Explorer moved this file to another destination document library and we got this error.
    What we have to achieve is users should be able to copy files and folders using
    Open with Explorer functionality. We don’t know why Open with Explorer
    functionality not work working for our environment.  
    Are we doing something wrong? 
    We have referred to following websites.
    we hope concepts of copying / Moving files are similar as SharePoint 2010. Our production environment is SharePoint 2013.   
    http://www.mcstech.net/blog/index.cfm/2012/1/4/SharePoint-2010-Moving-Documents-Between-Libraries https://andreakalli.wordpress.com/2014/01/28/moving-or-copying-files-and-folders-in-sharepoint/
    Please advise us. Thank you.
    Regards,
    Aroh
    Aroh Shukla

Maybe you are looking for

  • Junk mail filter not working properly

    About two weeks ago mail started marking lots of messages as "Junk". Even messages (reminders) I send myself are marked as junk. This is entirely new and I don´t have a clue of what triggered the change in behavior. I have turned off the junk mail fi

  • How to invoke custom classes from logon PAR

    Hi all, Can someone tell me how I can invoke a java class that I have written on Click of a Submit button from the Help Page of the Login Screens. I have to customise this screen, changing the existing functionality. Regards, Ashwini.

  • MPGs will not play in iPhoto 08

    I imported three mpgs from my digital camera into iPhoto 08 and they will not play. However is they are placed on the desktop QT opens and plays them. Get info shows them as mpgs and the size. They did play in previous versions of iPhoto. Running Sno

  • Replacement Path Variable

    I have one variable for 0CALWEEK which is an input variable. Now I want to extract week number from this variable value. Ex. 0CALWEEK = 200850 I want to extract 50 from this variable for calculation purpose. How to proceed for the same using replacem

  • OS 4 disaster, how do you roll back to 3.13 (or whichever was the previous

    Hi all, first time poster. First of all with previous OS's not a problem, however this one is possibly not even worthy of OS 0.4 never mind 4. I've been following everyones guide on how ot cope with the poor battery life (which likes to drain complet