1

I need a simple batch script which parses this string and get the filename from it:

OTR-Tool, v1.1.0
&FN=Filename.avi
&FH=EAA7508AAAD86AA4D8FAAE404BAFFA8729AA9C80AA4C8CBA
&OH=7FA2FAB108329105401003EAE224721BAFFA962E98F72750
&Sw=FALSE
&SZ=1198525032
&H=426060A8B8829808B8EAB802B0926082

I tried this:

for /f "tokens=1,2 delims==" %%A in ('%~dp0otrtool\otrtool.exe %1') do if "%%A"=="&FN" set FN=%%B

But this doesn't work. I just get the entire output. Quick help somebody?

upd I tried also to execute just the following

otrtool.exe filename.key | find "&FN"

but I get the entire ouput again.

9
  • the file name is the first line?What's the final value of FN? Commented Sep 24, 2014 at 18:51
  • What's the final value of FN? Commented Sep 24, 2014 at 18:53
  • redirect the output to a file and check if it's in unicode. Commented Sep 24, 2014 at 18:58
  • I can't do it for some reason. otrtool.exe > test.txt should output the usage information of this program into the file. Though the file is created, its size is 0 bytes and the output of the executable goes to the console. Commented Sep 24, 2014 at 19:04
  • 1
    most probably it outputs to stderr.Try with otrtool.exe > test.txt 2>&1 Commented Sep 24, 2014 at 19:08

1 Answer 1

3
for /f "tokens=1,2 delims==" %%A in ('%~dp0otrtool\otrtool.exe %1 2^>^&1') do if "%%A"=="&FN" set FN=%%B

try like that.

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

2 Comments

Thanks for the workaround. I should probably contact the developer or even try to fix the code by myself since I have the sources.
Or maybe just leave it as it is :) It works after all! Спасибо.

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.