Alfred-Chris Posted August 28, 2021 Posted August 28, 2021 Hello dear Alfred forum members I am new to Alfred and am already enjoying using it. There is one workflow that I would like to create and it seems fully out of my capabilities. Basically I would like to file an email attachment into a folder that is names with date and then the attachment file name and move it to a specific folder. Is this something that can be done with Alfred? All I have so far is a Universal Action called "FilingCustom" but then I already stop because I can't see how to create a folder. I guess it needs scripting from here? Or could Alfred do that with its own tools and someone could guide me into the right direction? That would be very much appreciated 🙂 Greetings, Chris
deanishe Posted August 28, 2021 Posted August 28, 2021 (edited) Hi @Alfred-Chris, welcome to the forum. It sounds like it's probably possible, but you're going to have to provide a significantly more precise description of what you're trying to achieve if you want actionable advice. 4 hours ago, Alfred-Chris said: Basically I would like to file an email attachment into a folder that is names with date and then the attachment file name and move it to a specific folder. I mean, what are we talking about here? Is the folder named with the date the same folder as the "specific folder"? This is too vague to give you anything useable. Edited August 28, 2021 by deanishe
Alfred-Chris Posted August 28, 2021 Author Posted August 28, 2021 Hi deanishe Thanks a lot for answering and I ca see that you are absolutely right. Let me try and explain better. The workflow would be: - Email with attachment arrived - The attachment's filename is "Project1-100-001-B - Document name.pdf" - I highlight the attachment inside the email and trigger the Alfred Action Menu - In here I would like to have an action that will do the following: - Create a folder that has the format "Date added - Attachment's Filename" in a specific folder (e.g. inside "Documents") - (example here: The folder would be called: "2021-08-28 - Project1-100-001-B - Document name" - The attachment will be copied into that folder - Ideally: The folder will be tagged "yellow" That's it. I hope it makes a more sense now. And thanks again for any help in advance already 🙂 Chris
deanishe Posted August 28, 2021 Posted August 28, 2021 (edited) That's a really good description. Thanks. One immediate issue, though: 6 minutes ago, Alfred-Chris said: I highlight the attachment inside the email and trigger the Alfred Action Menu In which email program? None of the email clients I use allow you to action attached files in Alfred. Edited August 28, 2021 by deanishe
Alfred-Chris Posted August 28, 2021 Author Posted August 28, 2021 (edited) I use Spark from Readdle and it works in there. I attached a short screenshot where you can see how Alfred addresses the file inside the filesystem of the mailbox, in case you are interested. I can't say that I can recommend Spark though, for the reason that the company finances itself trading with your data. Edited August 28, 2021 by Alfred-Chris
deanishe Posted August 28, 2021 Posted August 28, 2021 Just now, Alfred-Chris said: I can't say that I can recommend Spark though, for the reason that the company finances itself using trading with your data. Yeah. I wouldn't touch Spark with a bargepole for precisely this reason. I don't know if they still do, but they also used to misrepresent Spark as a privacy-respecting email client. This workflow should do what you want. It's called "Save Attachments", but it will work with any files. It defaults to saving files to ~/Documents, but you can change that in the workflow's settings sheet. Alfred-Chris 1
Alfred-Chris Posted August 28, 2021 Author Posted August 28, 2021 Wow, this is amazing! I did not expect such great help, so many many thanks for the workflow and I hope it will also help someone else one other day! I will need to understand coding, that's for sure. And it will be very helpful that I can experiment with the workflow you sent me now and can try and understand this a bit better. Kind Regards, Chris
Alfred-Chris Posted August 28, 2021 Author Posted August 28, 2021 41 minutes ago, deanishe said: 🍺 Buy me a beer I just saw that - I bought you a beer 🙂 Cheers!
deanishe Posted August 28, 2021 Posted August 28, 2021 (edited) 2 hours ago, Alfred-Chris said: I just saw that - I bought you a beer 🙂 Cheers! Thanks very much! It took me a bit to figure out why "YNA" had sent me money. I'll invest it in a Herrengedeck Edited August 28, 2021 by deanishe
Alfred-Chris Posted September 1, 2021 Author Posted September 1, 2021 Hi @deanishe This all works very well. Thanks again. May I ask one follow up question on this topic. Currently when the email has several PDF files all get files in their own dedicated folder. As epxected! Would it also be possible to combine those PDF's in one folder? Probably to keep it simple the name could just be the "added-date" and then the name of the first PDF file, if that makes sense. Or is this tough to program?
Alfred-Chris Posted March 28, 2022 Author Posted March 28, 2022 This script always worked perfect. But (it seems) since the latest MacOS update I get the error message Reason: Couldn't posix_spawn: error 2 The external script may not exist, or doesn't have execute (+x) permissions. I saw @deanishe explanation on the link below, but I am not siure how to fix this. I tried to remove and then add Alfred from "Accessibility" inside the privacy settings menu. But it didn;t help to solve the issue. Does it require to rewrite the script for Alfred?
vitor Posted March 28, 2022 Posted March 28, 2022 6 hours ago, Alfred-Chris said: But (it seems) since the latest MacOS update I get the error message If you’re on Monterey 12.3, you’ll need further fixes. Reinstall Python 2. Redownload and reinstall the Workflow, to regain the executable bit. Open the Workflow in the Finder. Locate the save_attachments.py file and open it in a text editor. Change the top line from #!/usr/bin/python to (if you are on an Intel Mac) #!/usr/local/bin/python or (if you are on Apple Silicon) #!/opt/homebrew/bin/python. Alfred-Chris 1
Alfred-Chris Posted March 28, 2022 Author Posted March 28, 2022 Thanks a lot for the explanation, Vito! Very much appreciated. yes, I am on Monterey 12.3.
Alfred-Chris Posted May 16, 2022 Author Posted May 16, 2022 Hi, sorry to ask again. Is it possible somehow for me to convert the workflow that Deanishe once created from Python 2 to Python 3? Is there maybe a manual for that? I would like to try it instead if frickeling with MacOS (now and in the future). Thanks for any tip 🙂
giovanni Posted May 16, 2022 Posted May 16, 2022 @Alfred-Chris I can't test it on Spark, but can you try this version?
Alfred-Chris Posted May 17, 2022 Author Posted May 17, 2022 Hi Giovanni - thanks a lot for converting the workflow. At the moment I can't get it to work unfortunately. It doesn;t even show up in the drop down menu when I use the shortcut on the file. But I will try again when I have more time. Thanks again and more later, Chris
Alfred-Chris Posted May 17, 2022 Author Posted May 17, 2022 I get this error message in the log. I will try and look at the .py file myself a bit later. Quote [12:15:40.927] Logging Started... [12:16:07.857] Save Attachment[Universal Action] Processing complete [12:16:07.860] Save Attachment[Universal Action] Passing output '/Users/ck/Library/Group Containers/3L68KQB4HG.group.com.readdle.smartemail/databases/messagesData/9/280400/example.pdf' to Run Script [12:16:07.997] ERROR: Save Attachment[Run Script] Traceback (most recent call last): File "/Users/ck/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.4F8296F6-812D-4017-B9FE-08B804951DE9/save_attachment.py", line 16, in <module> from Cocoa import NSURL ModuleNotFoundError: No module named 'Cocoa'
Alfred-Chris Posted May 17, 2022 Author Posted May 17, 2022 Ok, I guess this means that it doesn't find the right Python (python3) installation. If someone knows what to do to make it work, that would be cool, elsewise I will need to google my way through it. Talk later 🙂
vitor Posted May 17, 2022 Posted May 17, 2022 1 hour ago, Alfred-Chris said: I guess this means that it doesn't find the right Python (python3) installation. No, it means it’s missing a package. One which used to ship with macOS but no longer does, to make a bridge between Python and the macOS APIs. Running python3 -m pip install PyObjC in the Terminal may fix it. giovanni 1
Alfred-Chris Posted May 18, 2022 Author Posted May 18, 2022 19 hours ago, vitor said: Running python3 -m pip install PyObjC in the Terminal may fix it. Unfortunately that didn't fix it yet. I got the same error message. I am not sure how to address this issue.
Alfred-Chris Posted May 18, 2022 Author Posted May 18, 2022 I found this thread, and I wonder of this is somehow related to my issue: https://groups.google.com/g/pymacadmin/c/9mxMerTHdBg
Alfred-Chris Posted May 23, 2022 Author Posted May 23, 2022 Juhuuu! This worked! 🙂 Thanks so much for your help 🙂
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