I’ve got a project where I am writing a script that fixes File Type and Creator Type information that has been stripped from files.
The detection involves a combination of:
–check extension
–matches against known naming standards
–scan of the file “header” for known strings
So for example, a file ending in “.eps” and a positive match for “Creator: Adobe Illustrator(R) 8” in the header is known to be an Illustrator 8 EPS file and should be of File Type = EPSF and Creator Type = ART5 (the Illustrator version is simply logged, since all Illustrator files share the same type/creator in this case).
The criteria are all unique, so once a file is found to meet one set of criteria, thus can be repaired, the script should stop checking against any remaining criteria.
So the idea is:
CRITERIA1 = at least two dependent checks (CHECK1 & CHECK2 are TRUE)
CRITERIA2 = at least two dependent checks (CHECK3 & CHECK4 are TRUE)
CRITERIA3 = at least two dependent checks (CHECK4 & CHECK6 are TRUE)
IF ANYOF CRITERIA = TRUE
THEN load variables with values associated with found CRITERIA
So…
IF CRITERA1 = TRUE
THEN variable1 = value1, variable2 = value2
I have about three dozen checks like this. I’m looking at one really ugly nest if-the-else setup. I had already planned to put the most common files at the top of the if-then-else so it is more likely to stop early. But this seems inefficient somehow, and I was wondering if there is some other structre I could use to do this lookup.
Thanks in advance for your help,
–Kevin