Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

VBS Script to Delete Folder's Contents...


(!)

jwinathome's Avatar
jwinathome jwinathome is offline
Senior Member with 319 posts.
THREAD STARTER
 
Join Date: Mar 2007
Experience: Advanced
13-Mar-2007, 11:29 AM #1
VBS Script to Delete Folder's Contents...
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.
jwinathome's Avatar
jwinathome jwinathome is offline
Senior Member with 319 posts.
THREAD STARTER
 
Join Date: Mar 2007
Experience: Advanced
13-Mar-2007, 01:45 PM #2
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
tsiris's Avatar
tsiris tsiris is offline
Computer Specs
Junior Member with 7 posts.
 
Join Date: Jul 2004
Location: Greece, Thessaloniki (Halastra)
Experience: Beginner
14-Mar-2007, 04:44 PM #3
The script you gave deletes only files in this directory. How can we make it to delete folders as well?
jwinathome's Avatar
jwinathome jwinathome is offline
Senior Member with 319 posts.
THREAD STARTER
 
Join Date: Mar 2007
Experience: Advanced
16-Mar-2007, 10:29 AM #4
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

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑