Is there any way to do a search for what file ISN'T in a folder?

Celestial Avenger

Limp Gawd
Joined
Jul 12, 2005
Messages
414
Let's say I've got like.. 18,000 folders, and every one of them has to have the same default.asp file in it. I need to be able to find the folders that don't have this fast.

Thanks.
 
You could write a script that goes through all the folders and checks if the file doesn't exist in it, and if it doesn't exist, then it prints the path to a text file.
 
BillLeeLee said:
You could write a script that goes through all the folders and checks if the file doesn't exist in it, and if it doesn't exist, then it prints the path to a text file.

That's be great if I knew how!
:D
 
Celestial Avenger said:
That's be great if I knew how!
:D

Are you running windows? Do you have any scripting support like Perl/Python, or just what Windows provides?

I'll see if I can whip up something for ya.
 
Okay, you're in luck (I think). I'm not too good with VBScripting, but I whipped this up and it should do what you want.

Code:
Dim strTopPath
' set strTopPath to the top level directory to search
strTopPath = "d:\testdir"

Dim objFS
Dim outputFile
Set objFS = CreateObject("scripting.filesystemobject")
Set outputFile = objFS.createtextfile("C:\defaultSearch.txt", True)

RecurseFind (objFS.getfolder(strTopPath)), outputFile
MsgBox "Search finished"

Sub RecurseFind(objCWD, objOutputFile)

	Dim strFileName
	Dim objSubfolder
	Dim objTempFS
	Set objTempFS = CreateObject("scripting.filesystemobject")
	strFileName = "default.asp"
	
	Dim strFilePath
	strFilePath = CStr(objCWD.path) & "\" & strFileName
	
	If (objTempFS.FileExists(strFilePath) = false) Then
		objOutputFile.writeline CStr(objCWD.path)
	End If
		
	'go through all subdirectories
	For Each objSubfolder in objCWD.subFolders
		RecurseFind objSubfolder, objOutputFile
	Next
	
End Sub

Yes, it is ugly and I probably didn't code it very well, but I just learned VBScript this week so I'm still rough. :D

You will have to change some variables though, as I will doc here:

Code:
strTopPath = "d:\testdir"

My code assumes that these 18000 folders are not scattered all over the place (though it *shouldn't* matter) and that they have some top level directory that's not like C:\ (in which case it will probably take a while to run).

strTopPath is the top level directory where the program should begin searching. Change it. For example, if all the folders are under "C:\Windows\Folder1", then the line should look like this:

Code:
strTopPath = "c:\windows\folder1"

It's case-insensitive, so you can use lower case, upper case, whatever.

The script will then start that directory and go through all the subdirectories recursively, and will generate a text file in C:\ called "defaultSearch.txt"

The text file will have a list of directories which don't contain the file "default.asp"

Instructions:
1.) copy and paste script into a text file. Save the text file as "search.vbs" or something else, as long as it ends with ".vbs" extension.

2.) double click the .vbs file.

3.) When the text window saying "search finished" pops up, you're done.

Hope that helps.

edit: after rereading the original post - I have a question: What if the folders default.asp files, but they're not the same (as in not same text inside them)? :confused:
 
I get "VBScript runtime error, permission denied."

Probably some security measure. Blah, I guess I have to do this manually.
 
Celestial Avenger said:
I get "VBScript runtime error, permission denied."

Probably some security measure. Blah, I guess I have to do this manually.

What are the permissions on the folder(s) you're using this on? Are you a regular user or administrative (or power user, etc.)?
 
I'm a temp-to-hire working for a ginormorous company. I'm not going to get the permissions. Oh well, it's a job they need done by like.. January anyway.

Thanks for the help though!
 
Back
Top