Vbscript delete files using wildcards




















What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

All rights reserved. Covered by US Patent. Come for the solution, stay for everything else. Welcome to our community! I have the attached vbscript that will delete all files in a folder based on age. I need to modify it to delete files in a folder based on filenames containing a certain text string only.

There are mulitiple files in a directory that look like this MPMG VoiceReminderConfir mation. The MPMG01 and date field will change. Attached is my current code. Files older than this will be deleted. GetFolder strDirectory for each objFile in objFolder. Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search.

I found a way to suppress the error message and execute the DeleteFile. It worked for me. The better option is just suppress the errors from the delete and run the DeleteFile Command.

Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 9 years, 5 months ago. Return oBag Else Call oBag. Return oBag End If. Attachments: Up to 10 attachments including images can be used with a maximum of 3. Have a look at these two articles both on websites other than this one : Tek-Tips - Finding a file using a wildcard.

Your other choices might be to use a batch file which will happily use wildcards, though I suspect you're using VBS because SCOM won't run batch files, in which case, fair play to you! FileExists function does not support wildcard. As Jeff suggested, we may use a function to achieve this however, the sample code contains some minor error since VB script does not support LIKE operator. Steps required to remove the connectors from SCOM.



0コメント

  • 1000 / 1000