Need a script to scan computers for mp3 files and generate a list

I need a script to scan a list of computers (that are part of an OU in a domain) for mp3 (or other audio and video) files and generate a list.
LVL 14
Ehab SalemIT ManagerAsked:
Who is Participating?
sungenwangConnect With a Mentor Commented:
The sample vbscript below will read from a file (C:\Computers.txt) and search all the "mp3" & "wma" files in C: drive, then output to a log file (C:\Files.log).

This will take some time to run.

strComputerList = "C:\Computers.txt"
strFileList = "C:\Files.log"
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
arrComputers = Split(objFSO.OpenTextFile(strComputerList).ReadAll, vbCrLf)
For Each strComputer in arrComputers
	Dim objOut : Set objOut = objFSO.CreateTextFile (strFileList)
	Dim objWMI : Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	Dim colFiles : Set colFiles = objWMI.ExecQuery ("Select * from CIM_Datafile Where Drive = 'C:' And (Extension = 'mp3' OR Extension = 'wma')")

	For Each objFile in colFiles
		objOut.WriteLine strComputer & ": " & objFile.Name

	Set objOut = Nothing
	Set colFiles = Nothing  
	Set objWMI = Nothing
Set objFSO = Nothing
msgbox "done!"

Open in new window

michkoConnect With a Mentor Commented:
I don't have script to do that, but here is a program that will do what you're asking:

Hope that helps.
Danny ChildIT ManagerCommented:
Dir *.mp3 /s > c:\mp3list.txt
Ehab SalemIT ManagerAuthor Commented:
Thank you.
Although Mitchko solution is great I cannot use it for 2 reasons:
1- The domain contains hundreds of computers and the list is (for me) more practical.
2- I am not allowed to install freeware.
I'm glad you got what you needed - and thank you for the assist.
Best of luck to you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.