Jump to content

ClipSaver v2.0.4 - save image(s) from clipboard history to various formats


Recommended Posts

Update: v2.0.4 is out with some enhancements.

 

Hey guys,

 

Thought I'd share this little workflow. I found myself often needing to dump out the last N clipboard images from Alfred's history to disk. It was tedious before, find the right item, copy it back to the pasteboard, paste into Preview, save as PNG, give it a non-overlapping name, etc. So I created this to make it semi-automatic. Shouldn't need anything special, but please let me know if you run into any trouble.

 

Feedback welcome! One thing for sure I would like some advice on is whether the Script Filter (Python) could be turned back into a List Comprehension which from what I've read is more efficient. I couldn't figure out how to do that and also dynamically update the database rows (e.g. converting "/" to " / " so that Alfred's word matching would match correctly, picking a nicer generic icon when app name==null etc). @deanishe if you have time I'm sure you know the answer to this... :) 

 

 

image.thumb.png.21ed385016b65e853eac50dde6a061b9.png

 

GitHub

https://github.com/luckman212/alfred_clipsaver_workflow

 

Download Latest Release:

https://github.com/luckman212/alfred_clipsaver_workflow/releases/latest/

 

 

Edited by luckman212
Link to comment

Just to clarify what I was asking about above with the List Comprehensions, I'm talking about this.

 

Populating the list using List Comprehension

items = []
with database(dbpath) as db:
    rows = db.execute("SELECT foo...)
    items = [{ "title": r[1],
               "arg": r[0]
             } for r in rows ]

Populating the list using a loop and append (this is the current method used)

items = []
with database(db_path) as db:
    rows = db.execute("SELECT bar...)
    for r in rows:
      if r[2] == None:
        (...do stuff...)
      else:
        (...do other stuff...)
      items.append({ "title": r[1],
                     "arg": r[0]
                   })

My question is, is there a way to use the List Comprehension method while still allowing for the if/then/else code to execute?

Link to comment
2 hours ago, luckman212 said:

My question is, is there a way to use the List Comprehension method while still allowing for the if/then/else code to execute?

 

Not in this case, no. But forget about it. The difference in performance is absolutely miniscule and list comprehensions should be used sparingly. Readable code is more important that the tiny bit of speed you get from replacing a loop with a list comprehension.

 

2 hours ago, luckman212 said:

if r[2] == None:

 

if r[2] is None: is the more idiomatic way to test for None.

Link to comment
  • luckman212 changed the title to ClipSaver v2.0.0 - save image(s) from clipboard history to various formats
  • 1 month later...
  • luckman212 changed the title to ClipSaver v2.0.4 - save image(s) from clipboard history to various formats

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