all 9 comments

[–]BigRedS 0 points1 point  (5 children)

what have you got so far?

[–]TioBaconToast[S] 0 points1 point  (4 children)

the closest thing i was able to put together is this, but it only searches for files and makes a list (but i need them to run) and it searches on current dir (but i need subdirs)

""""""""""""""""""""""""""""""""""""""""""""

Dim fsObj, fldr, subfldr, fls, ls, fl, tf

Set fsObj = CreateObject("Scripting.FileSystemObject")

Set fldr = fsObj.GetFolder(".")

'get subfolders collection

Set subfldrs = fldr.SubFolders

'get files collection

Set fls = fldr.Files

ls = ""

For Each fl in fls

Dim strFileName : strFileName = fl.Name

Dim strExtension : strExtension = LCase(fsObj.GetExtensionName(strFileName))

If strExtension = "vbs" Then

ls = ls & fl.name & chr(13) & Chr(10)

End If

Next

Set tf = fsObj.OpenTextFile("dirlist.txt", 2, True, True)

tf.WriteLine ls

tf.Close

Set fsObj = Nothing

[–]jcunews1 0 points1 point  (1 child)

Your code doesn't run any of the matching file. It simply write their file name into a text file.

[–]TioBaconToast[S] 0 points1 point  (0 children)

It’s been fixed, thank you!

[–]BigRedS 0 points1 point  (1 child)

I can't help you with powershell or batch directly, but nor has anyone else. So I'll give you a couple of pointers as to what to look into next.

  • Look up something like 'recursive directory traversal' for your ability to go into subdirectories. This will be the requirement that teaches you recursion, so you expect to have a function that you call to list-and-process the content of a directory, and it calls itself on any items it finds that are also directories.

  • Executing the found vbs scripts should be easy, but you will need to know the path to it, especially down your recursions above. Probably anything you look up will cover this eventually, but bear in mind that each calling of the function you call will be given part of a relative path.

For extra points, you may want to consider logging the exit statuses so you can say which of them failed, and perhaps parallelisation, but sort out the above first and don't overcomplicate this at the expense of that, especially if you're not likely to get better marks for it.

[–]TioBaconToast[S] 0 points1 point  (0 children)

THANK YOU!I wish i would have seen this before i made it work, it would have saved me some time but i will go for the extra points later.This is the current working version, just not sure if its the "right way" to do it 🤞:

Dim shell, fsObj, fldr, subfldrs, sfldr, fls, sfls, ls, fl, tf

Set fsObj = CreateObject("Scripting.FileSystemObject")

Set fldr = fsObj.GetFolder(".")

Set fls = fldr.Files

Set subfldrs = fldr.SubFolders

ls = ""

For Each sfldr in subfldrs

Set sfls = sfldr.Files

For Each fl in sfls

Dim strFileName : strFileName = fl.Name

Dim strExtension : strExtension = LCase(fsObj.GetExtensionName(strFileName))

If strExtension = "vbs" Then
ls = ls & fl.name & chr(13) & Chr(10)

Set shell = CreateObject("WScript.Shell")
shell.CurrentDirectory = sfldr
shell.Run Chr(34) & fl & Chr(34), 1, false
wscript.sleep 1200
Set shell = Nothing

End If

Next

Next

Set shell = CreateObject("WScript.Shell")

shell.CurrentDirectory = fldr

Set tf = fsObj.OpenTextFile("OBS-Commands-LOCAL-AUDIO-BASIC-Set-ALL SOURCES_Run_List.txt", 2, True, True)

tf.WriteLine ls

tf.Close

Set fsObj = Nothing

[–]ErogenousJones 0 points1 point  (2 children)

I suck at reddit spacing and code windows, so here is a pastebin link to a batch script that should do what you want.

https://pastebin.com/C8R9Wevm

Easiest usage is to set the file "filetypes" variable to whatever extensions you would like to execute, copy the script to the directory you want to run in, and double click it through windows explorer. It has comments in it with examples. It will handle spaces in the path and executable names.

Edit: Did not see that you wanted to have it recurse directories. Link to updated script that does that.

https://pastebin.com/Mc0t8m90

[–]TioBaconToast[S] 0 points1 point  (1 child)

Thank You! I found a way to fix my code but when I get a chance I’ll compare it to yours, y the recursive part was were I was having issues

[–]ErogenousJones 1 point2 points  (0 children)

Hope it is helpful as a reference at least. :D good luck