1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VBS Script to Delete Folder's Contents...

Discussion in 'Software Development' started by jwinathome, Mar 13, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. jwinathome

    jwinathome Thread Starter

    Joined:
    Mar 9, 2007
    Messages:
    319
    I apologize for posting this in the wrong section before!

    Problem: User's temp folders that store recently opened PDF files gets full and has to be manually emptied so they can continue to open PDFs. Is there a script I can create to do this automatically? Maybe something the user can run on their PC when it happens?

    Thanks for your suggestions.
     
  2. jwinathome

    jwinathome Thread Starter

    Joined:
    Mar 9, 2007
    Messages:
    319
    Never mind, I got it. In case anyone is interested:


    dim aweekago
    dim dir

    dir = "C:\Documents and Settings\jwingate\Local Settings\Temp"
    aweekago = date -1

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldr = fso.GetFolder(dir)
    For Each file In fldr.Files
    If file.datecreated < aweekago then file.delete
    Next
     
  3. tsiris

    tsiris

    Joined:
    Jul 27, 2004
    Messages:
    7
    The script you gave deletes only files in this directory. How can we make it to delete folders as well?
     
  4. jwinathome

    jwinathome Thread Starter

    Joined:
    Mar 9, 2007
    Messages:
    319
    I think that is a bit more tricky, and Everything has to be cleared in the folder before the actual folder can be deleted, or something like that. I saw the script for it, but its crazy complex for a person that doesn't know scripting (like me!)

    I really only needed the script to empty this temp folder for my users.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/551405