0

I'm using a batch file to identify and load fonts temporarily. It looks for strings like /FontFamily(Rubber Dinghy Rapids)/ occurring inside .ai and .pdf files.

Now if I do findstr /r FontFamily\(.*\) MyFile.ai, this command returns a hugely interminable line of crap data with FontFamily(Rubber Dinghy Rapids) lost somewhere in there. I ACTUALLY need it to return the value of .* it found inside - in this case Rubber Dinghy Rapids.

Can I do this more elegantly? Or maybe I can switch to using VBScript if it's more elegant there?

My current solution is slow as hell... nested for loops, with one of them delimiting the crap data by the ( character, then finding the line that says FontFamily(Rubber Dinghy Rapids then stripping out the FontFamily( string, leaving me finally with Rubber Dinghy Rapids.

1
  • 1
    Two hints: (1) you use a greedy star match .* but you should use a lazy star match .*? instead. (2) To extract just the font family name, you need to use a capture group. I doubt that this two regex features are available in findstr. May be grep or a javascript regex can better suit your needs. Commented Nov 19, 2013 at 22:16

1 Answer 1

1

I wrote an hybrid Batch-JScript program called FindRepl.bat that use JScript's regular expressions to search for strings in a file. Using my program you may solve your problem this way:

FindRepl.bat "FontFamily\((.*)\)" /$:1 < input.txt

You may get my program from this site.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.