Jump to content

Workflow Request → Append Selected Text to .txt File


Recommended Posts

Hello,

 

I am looking for a workflow that will append the selected text ( it will be plain text always in Textedit) into another archive text file.  That's it. The target archive file will not likely be open usually.

 

If I have to Select the text and then copy to clipboard first, that's fine. Ideally I would be able to just select the text then trigger the Alfred workflow with the Hotkey trigger (archive file gets opened, text appended, file gets closed) and then I will delete the selected text in my working text file (inside of workflow or manually)

 

Tried some Automator script but I couldn't configure the code syntax correctly.

 

From : http://chronicle.com/blogs/profhacker/scripting-101-a-very-gentle-introduction-to-applescript/44969

 

 

set theText to the clipboard 
set theFilePath to (“/Whatever/The Path/Actually Is”) & “Whatever the Filename is.txt”

set theFileReference to open for access theFilePath withwrite permission 
write ”
” to theFileReference starting at eof 
write theText to theFileReference starting at eof 
close access theFileReference

 

New to this.

 

Thanks for any help.

 

Ray

 

 

 

Link to post

Hello,

 

I am looking for a workflow that will append the selected text ( it will be plain text always in Textedit) into another archive text file.  That's it. The target archive file will not likely be open usually.

 

If I have to Select the text and then copy to clipboard first, that's fine. Ideally I would be able to just select the text then trigger the Alfred workflow with the Hotkey trigger (archive file gets opened, text appended, file gets closed) and then I will delete the selected text in my working text file (inside of workflow or manually)

 

Tried some Automator script but I couldn't configure the code syntax correctly.

 

From : http://chronicle.com/blogs/profhacker/scripting-101-a-very-gentle-introduction-to-applescript/44969

 

 

set theText to the clipboard 

set theFilePath to (“/Whatever/The Path/Actually Is”) & “Whatever the Filename is.txt”

set theFileReference to open for access theFilePath withwrite permission 

write ”

” to theFileReference starting at eof 

write theText to theFileReference starting at eof 

close access theFileReference

 

New to this.

 

Thanks for any help.

 

Ray

 

Just trying to append to a file could be done more easily via a bash script. For example..

echo "This is the text to append" >> somefile.txt

Would append the text to the end of somefile.txt

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...