hboon Posted March 29, 2014 Share Posted March 29, 2014 I created this workflow recently and wrote about it at Alfred Workflow to Capture Thoughts and Ideas to a Text File Without Disrupting Your Flow. From the README: This workflow for Alfred captures what you type and appends it to a text file of your choice. It’s very useful to capture quickly any thoughts or tasks that surface while you’re working and don't want to be distracted. 1. Double click the downloaded Capture to text.aflredworkflow file in Finder to install. 2. Double click the Run Script action and replace the file name ~/Desktop/cap.txt in the Script with your preferred file path. The file will be automatically created when the workflow runs if it doesn't exist. 3. Click Save. To use it, type capture, hit return and then any text and hit return again, and your input text will be appended to the text file. Go through the text file in batches when you are ready. Download link: http://motionobj.com/blog/alfred-workflow-to-capture-thoughts-and-ideas-to-a-text-file-without-disrupting-your-flow/ geoff, gammawert, CarlosNZ and 1 other 4 Link to comment
gammawert Posted March 29, 2014 Share Posted March 29, 2014 hi hboon, thanks for sharing this. so far i was doing exactly the same, but was always using a txt-editor, which i had to open first and then i tended to use an empty file for each idea // note - ending up with a million of opened txt files containing one liners. so this one comes in handy. one question: would it be possible to end each entry with two line breaks automagically? this way notes wouldnt be appended to each other but be separated in blocks. Link to comment
hboon Posted March 30, 2014 Author Share Posted March 30, 2014 one question: would it be possible to end each entry with two line breaks automagically? this way notes wouldnt be appended to each other but be separated in blocks. Sure, if you are comfortable with editing the script, open the workflow editor, double click on the Run Script stage, and modify the script from something like: echo "{query}" >> YOUR_PATH echo "{query}" to: echo "{query} " >> YOUR_PATH echo "{query}" and click Save. (Just place your cursor after the first } and hit return once/twice) Link to comment
2pilvic Posted April 1, 2014 Share Posted April 1, 2014 Fantastic, very good workflow, but, may add date and time for each entry? thanks Link to comment
gammawert Posted April 2, 2014 Share Posted April 2, 2014 echo "{query}" >> YOUR_PATH echo "{query}" to: echo "{query} " >> YOUR_PATH echo "{query}" Followed your advice, but didn't manage to get a line break this way. Do you have a different idea? Link to comment
gammawert Posted April 2, 2014 Share Posted April 2, 2014 Fantastic, very good workflow, but, may add date and time for each entry? thanks I managed to do it with this code in the script: echo "$(date): {query}" >> ~/Desktop/notes.txt echo "{query}" Since I don't need the time, I am using this code instead, which simply display the date: echo "$(date +"%B %d"): {query}" >> ~/Desktop/notes.txt echo "{query}" Still, without a proper line break - which I am not capable of creating, due to missing knowledge - the txt file is getting quite messy to read, so far. Moses 1 Link to comment
hboon Posted April 2, 2014 Author Share Posted April 2, 2014 Followed your advice, but didn't manage to get a line break this way. Do you have a different idea? Since it's line breaks – which isn't the most obvious to read – we might be talking past each other Try this: echo "{query}xx yy" >> YOUR_PATH echo "{query}" Do you observe the line breaks in your text file and the xx and yy "markers" appearing separated by empty line(s)? Link to comment
2pilvic Posted April 2, 2014 Share Posted April 2, 2014 I managed to do it with this code in the script: echo "$(date): {query}" >> ~/Desktop/notes.txt echo "{query}" Since I don't need the time, I am using this code instead, which simply display the date: echo "$(date +"%B %d"): {query}" >> ~/Desktop/notes.txt echo "{query}" Still, without a proper line break - which I am not capable of creating, due to missing knowledge - the txt file is getting quite messy to read, so far. It works perfect. Thank you very much, is what I was looking for. Link to comment
2pilvic Posted April 2, 2014 Share Posted April 2, 2014 Followed your advice, but didn't manage to get a line break this way. Do you have a different idea? echo " {query}" >> YOUR_PATH echo "{query}" Link to comment
gammawert Posted April 3, 2014 Share Posted April 3, 2014 Since it's line breaks – which isn't the most obvious to read – we might be talking past each other Try this: echo "{query}xx yy" >> YOUR_PATH echo "{query}" Do you observe the line breaks in your text file and the xx and yy "markers" appearing separated by empty line(s)? With exactly this code, I get the following result: Is it maybe textwrangler acting funny? Link to comment
hboon Posted April 3, 2014 Author Share Posted April 3, 2014 Oh, I see you are not seeing *any* linebreak at all. Can you launch Terminal and type this (replacing with the path to your cap file): cat YOUR_PATH It will print out the contents of the file. If you see line breaks there, maybe it's a TextWrangler setting to do with what it consider linebreaks. See if there's a setting mentioning Unix/Windows linebreaks and play with that. Link to comment
gammawert Posted April 4, 2014 Share Posted April 4, 2014 Oh, I see you are not seeing *any* linebreak at all. Can you launch Terminal and type this (replacing with the path to your cap file): cat YOUR_PATH It will print out the contents of the file. If you see line breaks there, maybe it's a TextWrangler setting to do with what it consider linebreaks. See if there's a setting mentioning Unix/Windows linebreaks and play with that. Found the solution, it was a wrong TextWrangler setting. Thank you for your help. Link to comment
Moses Posted May 12, 2014 Share Posted May 12, 2014 Thank you so much, I am using: echo "$(date +"%e %B %Y %H.%M"): {query}" >> /Users/user/Box\ Sync/Notational\ Data/RunningNotes.txt echo "{query}" Works great, Link to comment
Moses Posted May 13, 2014 Share Posted May 13, 2014 In my last post here, I am using Capture to append to a note maintained in nvAlt and Simplenote, I am syncing the two, it works great. Has anyone found a way to append to a note in Evernote, e.g. I tried to get the local path to an Evernote: /Users/user/Library/CoreData/com.evernote.Evernote/5CAC8460-FA3A-45CC-86FE-0194B25197F7/ENNote/_records/7/8/2/0 ... so far it is not working, any suggestions please, Link to comment
bseymore Posted May 14, 2014 Share Posted May 14, 2014 (edited) Sure, if you are comfortable with editing the script, open the workflow editor, double click on the Run Script stage, and modify the script from something like: echo "{query}" >> YOUR_PATH echo "{query}" to: echo "{query} " >> YOUR_PATH echo "{query}" and click Save. (Just place your cursor after the first } and hit return once/twice) Another option is to use echo -e "{query}\n" >> ~/Desktop/cap.txt echo -e "{query} The -e flag "enables interpretation of backslash escapes". The \n is a newline character, so just add one for each new line you want. Or, if you wanted to add a tab, it just add \t, which could work nicely when adding a timestamp: echo -e "$(date +"%e %B %Y %H.%M")\t{query}\n" >> ~/Desktop/cap.txt echo -e "{query}" Edited May 14, 2014 by bseymore Moses 1 Link to comment
peterpixel Posted June 5, 2014 Share Posted June 5, 2014 @hboon: brilliant workflow, just what I was looking for. Thanks a lot! I've modified the script a bit using the tips from this thread to correctly display the date & weekday "european-style" and separate the notes: export LANG=de_CH.UTF-8 export LC_ALL=de_CH.UTF-8 echo -e "————————————————————————————\n $(date +"%A, %d.%m.%Y - %H:%M") Uhr:\n{query}\n" >> ~/Desktop/Running\ Notes.txt echo -e "{query}" I had to set the locale for the script manually, else the script displays the english Weekday-names even though my system is set to swiss german. the result: ————————————————————————————————————————————————————————————— Donnerstag, 05.06.2014 - 15:14 Uhr: the first entry ————————————————————————————————————————————————————————————— Donnerstag, 05.06.2014 - 15:14 Uhr: the second entry ————————————————————————————————————————————————————————————— Donnerstag, 05.06.2014 - 15:15 Uhr: the third entry Link to comment
Moses Posted June 5, 2014 Share Posted June 5, 2014 Yes, lovely workflow, I am still trying to get it to write to Evernote, no luck yet, On another note, ;-), has anyone figured out how to get the workflow to append to the top of the target note rather than the bottom? I keep my target note, RunningNotes above, open in Textmate, which is recognizing the external change in the note and updating, works nicely, Link to comment
dfay Posted June 5, 2014 Share Posted June 5, 2014 "has anyone figured out how to get the workflow to append to the top of the target note rather than the bottom?" Many options here: http://superuser.com/questions/246837/how-do-i-add-text-to-the-beginning-of-a-file-in-bash Link to comment
Moses Posted June 5, 2014 Share Posted June 5, 2014 "has anyone figured out how to get the workflow to append to the top of the target note rather than the bottom?" Many options here: http://superuser.com/questions/246837/how-do-i-add-text-to-the-beginning-of-a-file-in-bash Thanks for the link, ... check out the reply from Rucent88, I was looking to append, but it is not going to work out because at the top of the file, I have, # NoteTitle = Notebook @ tag1 Time: 5 June, 2014 17.39 for the send over to Evernote, via MarkdowntoEvernote, Link to comment
dfay Posted June 5, 2014 Share Posted June 5, 2014 (edited) Edited 2014-06-07 to correct issues highlighted by deanishe below If you are willing to add a separator to separate the stuff at the top from each note, you can use this python script. In the "Run Script" element of the workflow, language should be set to python and Double Quotes should be escaped. (edited 2014-06-06 to remove extraneous line from testing). The script will write to an existing file, or, if the specified file doesn't exist, it will create a new file, based on a predefined template. The template is stored in two parts, a heading (theTemplate - see below), which can be edited in the target notes file without breaking the script, and a separator (theSeparator - see below), which should not be changed in the target notes file. To customize the script, there are four variables you can modify: notesFile - the filename for your notes theNote - as written, the script inserts the date and time followed by two blank lines ('\n\n') and the text from the command ("{query}"). You can delete the whole date section ("n.strftime('%Y/%m/%d %H:%M:%S')+") or change the formatting - I used the guidelines at http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/ ). theSeparator - I used '## Notes ##' b/c this will look nice in Markdown but is also unlikely to appear anywhere else. You can hypothetically use any text. You should not change this in your target notes file without also changing it in the script, or the script will stop working. theTemplate - I based this on the request earlier in these forums - again, this can be changed to whatever you want. #!/usr/bin/python from datetime import datetime import os notesFile = '/Users/your home/Desktop/notes.txt' # your path and filename go here n = datetime.now() theNote = n.strftime('%Y/%m/%d %H:%M:%S')+'\n\n'+"{query}" # to reformat the date see http://www.cyberciti.biz/faq/howto-get-current-date-time-in-python/ theSeparator = '## Notes ##' theTemplate = '# NoteTitle\n= Notebook\n@ tag1' if not os.path.exists(notesFile): with open(notesFile, 'w') as file: file.write('{}\n\n{}\n\n{}'.format(theTemplate, theSeparator, theNote)) else: with open(notesFile, 'r') as file: notes = file.read() with open(notesFile, 'w') as file: sections = notes.split(theSeparator,1) notes = sections[0]+theSeparator+'\n\n'+theNote+'\n'+sections[1] file.write(notes) Edited June 8, 2014 by dfay cands 1 Link to comment
Moses Posted June 6, 2014 Share Posted June 6, 2014 dfay, Thank you for posting this! I will endeavour to speed up progress on the learning curve, hope to report back here after much stumbling through, Best, Link to comment
dfay Posted June 6, 2014 Share Posted June 6, 2014 I've updated the post with my script to include some more explanation of what it does and how to customize it. Link to comment
deanishe Posted June 6, 2014 Share Posted June 6, 2014 notesFile = '/Users/your\ home/Desktop/notes.txt' # your path and filename go here There's no need to escape spaces etc. in Python: notesFile = '/Users/your home/Desktop/notes.txt' # your path and filename go here You should also replace the whole try ... except business with: if not os.path.exists(notesFile): with open(notesFile, 'w') as file: file.write('{}\n\n{}\n\n{}'.format(theTemplate, theSeparator, theNote)) else: with open(notesFile, 'r') as file: # read contents... with open(notesFile, 'w') as file: # re-write updated contents Catching all errors is frowned upon, and in particular, your code will overwrite the notes file if an error other than "file doesn't exist" occurs. Link to comment
Taxidiotis Posted June 7, 2014 Share Posted June 7, 2014 Thanks for the workflow; good job. I've noticed the following when capturing: Say that I wish to enter: "Do not forget to pay: Verizon Home: $119.86; Bill Me Later: $225.00; Credit One: $150.00. Said transactions have already been entered in YNAB; all you need to do is use BillPay account and enter aforementioned payments to their respective payees." The following is captured: "Do not forget to pay: Verizon Home: 19.86; Bill Me Later: 25.00; Credit One: 50.00. Said transactions have already been entered in YNAB; all you need to do is use BillPay account and enter aforementioned payments to their respective payees." Perhaps it has something to do with the symbol "$"? This I say because captures are not being recorded properly when anything is preceded by the $ symbol. The $ symbol itself is not being captured. Nota bene, I am using OS X v. 10.9.3. Once sorting out the aforesaid all shall be well on this front, for I find your workflow a welcome addition to my diurnal arsenal of Alfred's capableness. Thank you in advance for looking into this. Link to comment
deanishe Posted June 7, 2014 Share Posted June 7, 2014 (edited) That's a bug in the workflow. Open it up Alfred Preferences, select the Workflow and double-click on the central Run Script action. In the Escaping Options, make sure Backquotes, Double Quotes, Backslashes and Dollars are selected. Then Save your changes. That last option is the one that's messing things up for you. What's happening is that bash is replacing $1 (and $2 etc.) with its command line arguments (of which there are none). Edited June 7, 2014 by deanishe Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now