Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Deleting All Zip Files in a Folder

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,1326
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Deleting All Zip Files in a Folder
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Deleting All Zip Files in a Folder - 9/6/2004 4:06:29 AM   
  web_app_developer

 

Posts: 2
Score: 0
Joined: 9/6/2004
From:
Status: offline
Hi,

I am trying to convert the following NT Cmd Script to put into a vbs script:

del /Q \tmp\*.zip

When I try the following I get the message "The system cannot find the file specified"

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "del /Q \tmp\*.zip"
Set objShell = Nothing


The filesystemobject does not understand wildcards, so that avenue seems to be closed for me.

Any suggestions or feedback would be greatly appreciated.

Thanks!
 
 
Post #: 1
 
 Re: Deleting All Zip Files in a Folder - 9/6/2004 7:10:41 AM   
  devguy

 

Posts: 15
Score: 0
Joined: 7/31/2004
From: USA
Status: offline
Since 'del' is not a program but a command shell internal you will need to specify the command like this...

objShell.Run "cmd /k del /Q \tmp\*.zip"

(in reply to web_app_developer)
 
 
Post #: 2
 
 Re: Deleting All Zip Files in a Folder - 9/8/2004 2:40:30 AM   
  web_app_developer

 

Posts: 2
Score: 0
Joined: 9/6/2004
From:
Status: offline
quote:
Originally posted by devguy

Since 'del' is not a program but a command shell internal you will need to specify the command like this...

objShell.Run "cmd /k del /Q \tmp\*.zip"



Thank you so much!

(in reply to web_app_developer)
 
 
Post #: 3
 
 Re: Deleting All Zip Files in a Folder - 9/10/2004 3:19:33 AM   
  PharaohCC

 

Posts: 7
Score: 0
Joined: 9/10/2004
From: USA
Status: offline
Would it be faster to run a WQL query? I'm a little new to the querying with WMI so the syntax might be a little off, but it should work. Please correct me if I am missing something.

sComputer = "."
Set fso = CreateObject("Scripting.FileSystemObject")
sPath = "\\TEMP"
Set oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colFiles oWMI.ExecQuery("SELECT * FROM CIM_DataFile WHERE PATH = '" & sPath & "' AND EXTENSION = 'ZIP'")
For Each objFile in colFiles
Set objFiletoDelete = fso.GetFile (objFile)
objFiletoDelete.Delete
Next

(in reply to web_app_developer)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Deleting All Zip Files in a Folder Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts