Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DirectroryInfo - Exclude Known Good Files

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
I have a set of folders that should only have file names starting with exactly 6 numeric characters and the first three should always be the same in each folder (123111bol.tif,123989.pdf, etc.). Any files starting with 7 or more numeric characters are also misnamed. There are up to 2000 files in each folder. What I am looking for is a method of finding the files that don't match this naming structure. I can scan through all of the files for the bad ones, just thought there might be a way of excluding the known good files. I thought I saw an exclude feature in later versions, but this is VS 2003 and .Net 1.1.

Auguy
Sylvania/Toledo Ohio
 

If you show us your code of how you
can scan through all of the files for the bad ones,
somebody here will be able to help you.

Have fun.

---- Andy
 
Thanks Andy, I was hoping for some method of excluding the properly named files when using DirectoryInfo I'll start on looping through all of the files and posting back here to see if anyone can simplify my code.

Auguy
Sylvania/Toledo Ohio
 
...and the first three should always be the same in each folder
How will you determine what the "good" first three digits are versus the "bad" first three digits? For example, if 500 files begin with "123" and another 500 begin with "456", do you throw out the "123" files or the "456" files? Does the prefix with the most entries win out?
 
Dave, I should have explained a bit more. For example, if there is a folder 123000, then all the files in that folder should start with 123, and the folder 124000 should have only files that start with 124, etc. The fourth through the sixth charaters in the file name should be 000 to 999. The seventh character cannot be a number. Examples of good file names are: 123111bol.tif, 123989.pdf. Examples of bad file names are: 1231117bol.tif, 12398.pdf. Hope that clear up any questions

Auguy
Sylvania/Toledo Ohio
 
A possible hint: Have you considered using Regular Expressions to help the process. E.g. you can create a RegEx to create a list of all files that do not meet the standards.

Lion Crest Software Services
Anthony L. Testi
President
 
Not quite sure how to go about that. Right now I'm getting a list of all of the files and processing them one at a time to find the bad ones. I am using RegEx in this process to help find the ones that don't start with 6 numeric characters. Can you give me a hint as to how to use RegEx with DircetoryInfo?

Auguy
Sylvania/Toledo Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top