gatto Posted July 27 Share Posted July 27 Hi! I know how to get a pdf file content's with python, but is there a quicker way to get them directly with Alfred's workflows/actions/tasks/something?? Same thing with renaming: is it, in Alfred's "Automation tasks", the one titled "move path with the Finder"? My use case is to rename the latest pdf downloaded to the first line of its contents. I download lots of pdfs and this would in most cases rename them to their title (which is usually the first line in my use case) instead of their 5212583914.pdf name they usually have. Thanks! Link to comment
Stephen_C Posted July 27 Share Posted July 27 As to 1 I suspect (and no doubt someone else will jump in to correct me if I'm wrong) you'll need a text layer in the pdf file (i.e., it will have had to have been subject to OCR) before you can do that. As to 2, yes, I think you need either Copy Path with the Finder or Move Path with the Finder (depending upon exactly what you want to do). However, I have to say that I use Hazel for exactly that sort of thing. It's excellent…and has many other uses besides. Stephen Link to comment
gatto Posted July 27 Author Share Posted July 27 Well yes, the pdfs I read are all generated by software and therefore correctly code text as text. Thanks for the other software suggestion, but I'd like to insist and make this with Alfred, both for learning purposes and because damn I don't want to have to run 15 apps for each little thing I need. Link to comment
vitor Posted July 27 Share Posted July 27 2 hours ago, gatto said: I know how to get a pdf file content's with python Then you can do it with a workflow. All you need is a Universal Action Trigger and a Run Script Action. Perhaps a Copy to Clipboard Output too, depending on what you want to do with the text. 2 hours ago, gatto said: Same thing with renaming Same logic, but you can do it with a single mv command. I’m avoiding being too explicit with the solution because it seems you want to learn building workflows, and since you know how to code I don’t want to influence you too much on a particular direction. Have you checked the Getting Started Guide? It’s an interactive tutorial on making workflows. If you have any questions or get stuck, please do say so and I can be more specific with the solution. Link to comment
gatto Posted August 1 Author Share Posted August 1 (edited) @vitor thanks, actually, I can't figure it out. It might not be I must say the gentlest learning curve for "advanced" workflows. How do I pass multiple arguments from a python script back to Alfred? I understand that what I "print" becomes the output of the workflow cell, but can I maybe pass actual variables, so I can pass more than one, saving myself from parsing those values back and forth? Example use case: var1 = 5 var2 = "a_path" # code to pass those two variables to the next cell (bash script) # code to receive two variables cd $var2 mv … $var1 … Finally, is there a simple workflow implemented in python only (as for external scripts go) so I can look at how things are done usually? Edited August 1 by gatto Link to comment
vitor Posted August 1 Share Posted August 1 (edited) 12 hours ago, gatto said: How do I pass multiple arguments from a python script back to Alfred? By outputting a specific JSON format. arg can be an array or you can use variables. Edited August 2 by vitor Fixed typo Link to comment
gatto Posted August 2 Author Share Posted August 2 Thanks. Is there a workflow with scripts in python only? I found, as languages go, javascript, AppleScript, ruby, php and more, but no python. Link to comment
vitor Posted August 2 Share Posted August 2 (edited) Yes, Python is very popular for workflows. Check anything by @Acidham, for example. But what exactly are you looking for? There’s really not anything you can’t learn from the other scripting languages. You also shouldn’t need to be messing with multiple arguments or variables unless you’re straying from the original explanation. But without knowing exactly how you’re trying to modify it, I can’t point you in the right direction. Edited August 2 by vitor gatto 1 Link to comment
gatto Posted August 10 Author Share Posted August 10 Acidham is a great resource, I'm learning a lot! Yes, I'm definitely straying for what I initially wanted to do. I did what I was looking to do with this original post, but it's coded in a way (directories and such) that it only works for me. So I'm learning by reading other's work. 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