9

I want to use Evernote's ENScript.exe to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to be entered via a file or via standard input.

For my current workaround I use a .bat file to write the argument to a file, then call ENScript with the /s argument pointing to the file to read it in, but that forces the default title to the temporary file's filename (a behavior I do not want).

So my question is: Is there a way to "fake" standard input on the Windows command line so that I can use an argument (passed from another program) to generate the note text? The beginnings of the script would be something like

ENScript.exe createNote /i %1

with the standard input following.

1
  • Do you mean for your workaround you've been ENScript.exe createNote /s file.bat?
    – Zimba
    Apr 16, 2020 at 15:58

3 Answers 3

12

You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.

The pipe symbol for Windows CMD is |

Your script could be as simple as:

@echo %~2|@ENScript.exe createNote /i %1

If your script is called MakeNote.bat, you would call it like

MakeNote "your title" "This is the text of your note"
1

One can "fake" standard input by using redirection:

command args... < filename args...

where the < means input redirection ("read standard input from the filename after the < instead of the terminal").

(Note that old Windows or DOS programs may read straight from the terminal, making input redirection useless; this hopefully won't apply to something as recent as Evernote.)

For your example:

ENScript.exe < "%1"

Feel free to add more arguments before or after the redirection. For example, if your script will be called as script filename title, you will want to invoke ENScript /i "%2" < "%1".

4
  • The second "args..." makes no sense. If the data source is a command with or without arguments, use the | pipe instead of <.
    – Ben Voigt
    Apr 14, 2013 at 1:57
  • If I get the error "The system cannot find the file specified" when trying to test this, does that mean it will only work if it reads straight from the terminal? Just tried ENScript.exe createNote < "Testing 123 and got the error.
    – Ryan
    Apr 14, 2013 at 2:03
  • @BenVoigt The filename doesn't get the arguments; I was trying to demonstrate that where the redirection is on the command line is not important. @Ryan Do you have a file named Testing 123? That's what it will read the note text from. Apr 14, 2013 at 6:27
  • Ya, I see now that's the problem I don't want to have to create a file with the text. @dbenham's answer appears to do more what I'm looking for.
    – Ryan
    Apr 15, 2013 at 0:38
0
echo Note text>Title&ENScript.exe createNote /s Title

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.