0 votes

I use the following regular expression in an alternative tool to identify all .doc files in any subfolder containing the word electrical:

electrical[^\\]*\\[^\\]*\.doc.?$

Is there any way to do this in FLP?

asked by (1.2k points)

1 Answer

0 votes
 
Best answer

If you want to match the file AND folder in the same string you can do it using the Containing Text field. If you have the option Include folder path in content search then Line zero of the file will effectively include the full path to the file.

Include folder path

You can then limit the search to just line zero using the LINES operator, e.g. to find .doc files that are directly below a folder called 'electrical' you could use something like:

File name:       *.doc
Containing Text: LINES:0 REGEX "electrical\\[^\\]+\.doc"
Look In:         C:\

To speed up the search switch OFF Office/PDF Documents enhanced file searching in the Options tab unless you actually want to also search the contents of the DOC files.


Scripting alternative

In the Sample Scripts folder there is a file called path_regexp.js. Change the line:

bIsValid = regExp.test( strPath ); 

to

bIsValid = regExp.test( strPath + strFileName );

And this will compare the supplied regex to the whole path.


More information:

The 'normal' way to achieve this would be something like:

File name:        *.doc
Containing Text:
Look In:          C:\;+electrical

but this would find .DOC files where the term 'electrical' was anywhere in the path, not just the .DOC files parent folder.

answered by (58.6k points)
selected by
I'd prefer not to use scripting, but the "normal" method you suggested only appears to match the whole path rather than just the folder in which the .doc files live.  This results in a lot of false matches in sub folders that aren't relevant as the file matches are more than one level deeper.
Yes, it would be anywhere in the path. I've modified the answer to include a method of searching using the Containing Text field.
Excellent - works perfectly.  And I've learnt something new!  Thanks.
Just for the record, the regex in the Containing text line fails as it is different from my original.
...