How to create a rule in RuleWizard to check if the filename contains the foldername?

Options
nadine
nadine Posts: 3 ✭

I want to create a rule that checks if a filename contains the foldername at the beginning of the file, for example:

I have a folder named "folder1" containing a folder named "folder2" which contains a c file. This file should be named:
"folder1_folder2_myFile.c"

Is it possible to create such a rule with the rule wizard?

Comments

  • mstaron
    mstaron Posts: 35 ✭
    Options

    Yes, I think it is possible. You can use properties 'filename' and 'pathname' for the 'file' node. If you need to compare modified names, then you can use python method (File->Create Method->Boolean)

  • nadine
    nadine Posts: 3 ✭
    Options

    Thank you for your answer. It works so far with the python script. Now I wanted to check the filename with a regular expression inside the python script but to do that I need to import the python re module. Is there a way to use python modules in the rule wizard?

  • mstaron
    mstaron Posts: 35 ✭
    Options

    Yes, it is possible to use 'import re' in python methods in Rule Wizard. The example you can find in built-in rule PB-45 (getValueFromStringColA python method).