Question

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.

Was it helpful?

Solution

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"

OTHER TIPS

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".

echo Note text>Title&ENScript.exe createNote /s Title
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top