Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.

Steve Williams
I'm trying to capture some text from a list of file names. When I create a task "List Files" from the following folder
including the file mask "*.pdf" I get the following result.


I need to capture the "R" number text from each of the files found. See the following example below, we will use the 1st file in the list:
File name: CNB-160-SB_R815588.pdf
Text that needs to be captured: R815588
Forum information
Steve Williams
I did not realize but by hitting save it published the post. The rest of the question is that I tried the regex tool and used the following to parse the text I need:

But that did not return anything when I did a test show filtered files. The regex works on the regex test website,  ,

Morning, your question should really be under "general problem solving". Also there's an edit button to make changes to your original post.
Anyway, your unexpected results are most likely due to the fact that you are applying the regex from a task after the list files task and are thus operating on the STDOUT of the previous task which is the entire list at once, as opposed to creating a loop and operating on the output of the files a line at a time. Depending on what you are ultimately trying to do will call for one of these methods and an appropriate regex tailored to that method as the source strings will be different and you need to allow for that.

i.e. When operating on the previous task's STDOUT of the entire list, output is really one large string with embedded \r\n's in it that you have to allow for in the regex.

Do you really want to operate on a line at a time, or do you want the output to be a list of strings from the last part of filename in the path that follow the last underscore in the filename, start with an 'R', then 6 digits and end before the string '.pdf' at the end of the line?

Note I described what you want to return in painful detail as before you can come up with a regex you should be able to describe what you expect to be returned in plain language. That way you can analyze for mistakes like "whoa, the number of digits could be 1 or more, not strictly 6", or "start with an 'R' but any number of any characters, not just digits". See what I mean?

Please provide some more info. 🙂
After all that, maybe I lied or something changed since the version where I had an issue, or maybe I just learned. It can happen!
This seems to work to produce a list of what you want where the previous task's STDOUT is the list:


This form of regex breaks the line into 3 remembered groups, surrounded by parenthesis and referenced left to right by a number preceded by a $.
First is the first part of the string up to and including the last underscore. 2nd group is the set of characters starting with an 'R' and ending before the 3rd group which is the file extension literal dot pdf. replace all that with remembered group 2.

Note you could tighten it up by enforcing 6 digits after the 'R' like this:


Steve Williams
The following is a screenshot of the current structure which generates my list and creates a text file of the list.

This is the final variable code that works.

I appreciate the help to get me this far. Now I need to generate a custom .exe file from visual studio in C# or Java script to handle the special printer language we will be printing the barcode labels to. That will be the easy part. Then we will just run the executable in a new task after the Write file task.
Scroll to Top