I know that there's a way to use Automator to save text to a new text file.
But I want an Automator application that saves the text from clipboard to a GIVEN text file (by editing it, i.e. adding in the next line). Applescript would be okay too. Is there a way to do this?
Best Answer
You could use an Automator workflow/application using a Run Shell Script action with:
Notes:
Check out the manual page for:
pbpaste
You can read the manual page for
command
in Terminal by typingcommand
and then right-click on it and select: Open man PageThe
echo >> '/path/to/filename'
line adds a single line feed to the end of the file after the pasted text. You can add addition lines for more line feeds if you so choose.In place of the
echo
command you can also use, e.g.:Adding additional
\n
for more line feeds, e.g.'\n\n'
.If you update the file while it's opened, it is not doing to show the updated contents, you need to close/reopen the file to see additional updates to it.
If you want to do it with AppleScript, then in place of the Run Shell Script action, use a Run AppleScript action with the following example AppleScript code wish uses a slightly modified handler from Reading and Writing Files:
Notes:
The handler from the linked Apple support document was modified to handle both POSIX and HFS+ file paths.