Can I extract text from a text file, then dump the results into custom fields of that file?

Hi,

I searched for existing scripts, but I could not find something to match my needs.

I have text files with several paragraphs. One of the paragraphs has some data in this format:
String1: 0.8 String2: 0.4

I would like to capture the numbers (which are 0-1, inclusive), and then drop those into custom fields for that file (these custom fields would be named String1 and String2).

I can write Regex to capture, however, I do not know how to write a script to copy those data to custom fields.

Any resources or ideas?

Thanks,
Jason

OK, I found that a Smart Rule could do this, but I hit a block:
Screenshot 2023-03-28 at 10.39.35 AM

To be more specific, the line from which I am trying to capture text is something like:
Diff: 0.96 Disc: 0.08

And I am trying to capture “0.96” and change my custom field “Diff” to that. My capture Regex should work (it does in TextSoap, anyway). I have my custom field Diff formatted as single-line text (I learned that the rule could not pass the captured text to a decimal number field). However, when I run this rule, nothing happens (Diff is not changed).

Any thoughts/help?

Jason

A regular expression is probably not even necessary:

Works fine for your text example.

Thanks! This will be very helpful!

I changed it to move the result to my custom field, and it worked!

Best,
Jason

And to add to @cgrunenberg’s suggestion, from the Appendix > Smart Rule Events and Actions

2 Likes