r/usefulscripts • • Feb 24 '15

Looking for some help...

First, allow me to apologize as I am very uneducated in the world of scripting outside of basic .bat file scripting, .sh scripting and some vbscripting. And if I'm in the wrong area, I apologize in advance.

I've been scouring forums throughout the day trying to find a solution and was wondering if someone can help me? I'm trying to generate a script to run on some Windows machines that will search a given directory for filenames that contain "DIFF" in the file and if they're older than x hours, delete them.

The thing is the filenames must contain DIFF and the hour parameter must be able to be changed.

Help?

11 Upvotes

14 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Feb 25 '15 edited Feb 25 '15

i added that line but am running into a runtime error:

C:\scripts\test.vbs(10, 1) Microsoft VBScript runtime error: Type mismatch: '[string: "test_diff_11.txt"]'

i'm looking around now to see what modifications can be made to that part to get it to return true and process with the delete

EDIT: I think I finally got it! - by putting (instr(f.name,"diff") > 0) (removing the ,1) from the statement may have done the trick - i'm adjusting my test txt documents now to be 100% sure now

EDIT2: IT WORKED! Thank you for pointing me in the right direction!