Jump to content

Search for filenames within a folder


heero11yuy

Recommended Posts

Hi, please help on this problem:There are many files (*.htm) under 26 folders ( cam_a, cam_b, ..., cam_z )... and I got one word list (wordlist.txt, and of course can save it as xls)... what I needa do is to check every word in the wordlist.txt to see if they DON'T exist in the filename of *.htm under all 26 folders.What I don't know how to do is that:-how to get the word within the wordlist.txt automatically? (cuz there are over 36,000 words)-how to search for the filenames of the files(*.htm) under the 26 folders?My main problems are just can't get the datas... please help!by Roy

Link to comment
Share on other sites

So, you have a list of words (one word per line?) and 26 directories which may contain multiple files and you need to check the filenames for these files to verify that they do NOT contain words from your wordlist? Is this correct?If so, you'll be using the FileSystemObject. First step would be to use the FileSystemObject to open your txt file, read the contents one line at a time, and store the words in something like a Dictionary object.Then you'll want to use the FileSystemObject to find all of the directories (your cam_a, cam_b, etc) in a particular directory and then loop through all of those directories to get a list of all the files in each directory. You'll then need to loop through the files to get each individual file name. Finally, you'll have to loop through each word in your Dictionary and use some type of matching (e.g. regular expressions) to see if the filename contains your word.Sorry I don't have any code for you, I haven't used VBScript in a long time.

Link to comment
Share on other sites

So, you have a list of words (one word per line?) and 26 directories which may contain multiple files and you need to check the filenames for these files to verify that they do NOT contain words from your wordlist? Is this correct?If so, you'll be using the FileSystemObject. First step would be to use the FileSystemObject to open your txt file, read the contents one line at a time, and store the words in something like a Dictionary object.Then you'll want to use the FileSystemObject to find all of the directories (your cam_a, cam_b, etc) in a particular directory and then loop through all of those directories to get a list of all the files in each directory. You'll then need to loop through the files to get each individual file name. Finally, you'll have to loop through each word in your Dictionary and use some type of matching (e.g. regular expressions) to see if the filename contains your word.Sorry I don't have any code for you, I haven't used VBScript in a long time.
Thanks a lot, appreciated~! ^^In fact... I've got the logic, but I don't know how to do it technically... ><
Thanks a lot, appreciated~! ^^In fact... I've got the logic, but I don't know how to do it technically... ><
Actually, what is in the file if I use the filesystemobject? ( that's within a folder, not within a text file )
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...