Jump to content

Mimic Drafts' "Append to Dropbox" using Alfred


Recommended Posts

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 by subsmile
Link to comment
  • 2 weeks later...

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
  • 1 month later...
  • 3 weeks later...

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
  • 10 months later...

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