subsmile Posted April 10, 2013 Share Posted April 10, 2013 (edited) I'm just getting started with Alfred and scripting so please bear with me! The creator of Drafts has made an Alfred script to append to a file in Dropbox. I'm trying to figure out how to change the timestamp to the 24 hour format. I'd be very grateful if anyone would be kind enough to assist or point me in the right direction. Many thanks! EDIT: Apologies, I've just realised I've posted this in the wrong section... Here is the current script: # grab input text s = "{query}" # create insert value in template with timestamp tmp = "#{Time.now.strftime('%m-%d-%Y %I:%M %p')}\n#{s}" # path to file you wish to append... # folder path must exist, file will be created if it doesn't f = File.expand_path("~/Dropbox/Journal.txt") # open file in append mode and add the string open(f, 'a') do |f| f.puts tmp f.puts "\n" end Edited April 10, 2013 by subsmile Link to comment
_mk_ Posted April 10, 2013 Share Posted April 10, 2013 Should be tmp = "#{Time.now.strftime('%m-%d-%Y %H:%M')}\n#{s}" Link to comment
ericlundstedt Posted April 22, 2013 Share Posted April 22, 2013 any suggestions for how to make this a prepend at the beginning of the file, rather than append at end of the file? tried the google but got hopelessly lost in ruby documentation... thanks in advance. e. Link to comment
ericlundstedt Posted April 26, 2013 Share Posted April 26, 2013 found a way to do this. thanks to Osta for his workflow! http://www.alfredforum.com/topic/2175-quick-jot-workflow-collect-timestamped-stacking-jots-in-a-single-text-file/ Link to comment
jacg Posted April 28, 2013 Share Posted April 28, 2013 Hi. I've downloaded a "prepend to Dropbox" workflow and modified the start of the script to point to my text file. Please can someone tell me how to modify the script to add a line break in my text file after my note? Thanks! f=~/Dropbox/Apps/Text/Note.txt t=`mktemp /tmp/alfred_prepend.XXXXXXXX` q={query} cat - $f <<< $q > $t mv $t $f rm $t Link to comment
jbthree Posted May 31, 2013 Share Posted May 31, 2013 Is there a way to prepend in Ruby like the original script? Link to comment
ayn Posted June 21, 2013 Share Posted June 21, 2013 Hi there, I wrote the prepend workflow, to add a newline, just change it to something like: f=~/Dropbox/Notes/memo.txt t=`mktemp /tmp/alfred_prepend.XXXXXXXX` q=$'{query}\n' cat - $f <<< "$q" > $t mv $t $f rm $t Hi. I've downloaded a "prepend to Dropbox" workflow and modified the start of the script to point to my text file. Please can someone tell me how to modify the script to add a line break in my text file after my note? Thanks! f=~/Dropbox/Apps/Text/Note.txt t=`mktemp /tmp/alfred_prepend.XXXXXXXX` q={query} cat - $f <<< $q > $t mv $t $f rm $t Link to comment
Dellu Posted April 28, 2014 Share Posted April 28, 2014 thank you guys! very helpful script 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