mlondon Posted April 15, 2023 Share Posted April 15, 2023 I frequently need to create a new folder when using Alfred's "Move to..." Action. Is there a way to have Alfred create the new folder when using the Action? Note: I found an older Alfred 3.0 workflow here: https://www.deanishe.net/post/2019/06/workflow-new-directory-with-selection/ But it does not seem to work on Alfred 5.0.6 under macOS 13.3.1 I get the following error: Quote Reason: Couldn't posix spawn: error 2 The external script may not exist, or doesn't have execute (+×) permissions. Grateful for any help. Link to comment
pixelgeek Posted April 15, 2023 Share Posted April 15, 2023 What version of Python are you using? If you are running v3 then there is an error on line 56 of the Python script os.makedirs(newdir, mode=0755) Version 3 of Python requires that the mode is set using a different Octal format. So it would need to be changed to os.makedirs(newdir, mode=0o755) Try making tht change to the script and then running it. Link to comment
sepulchra Posted April 15, 2023 Share Posted April 15, 2023 @mlondon you may also want to explore these threads. These are two use cases that use automation objects Link to comment
mlondon Posted April 15, 2023 Author Share Posted April 15, 2023 1 hour ago, pixelgeek said: os.makedirs(newdir, mode=0o755) Try making tht change to the script and then running it. Thank you. I made the change, but still get the same error. I did try disabling and re-enabling the Workflow, and even quitting and restarting Alfred, but that didnt help Link to comment
mlondon Posted April 15, 2023 Author Share Posted April 15, 2023 1 hour ago, sepulchra said: @mlondon you may also want to explore these threads. These are two use cases that use automation objects @sepulchra Thank you, but these are both too complex and don't really address my need. Link to comment
pixelgeek Posted April 15, 2023 Share Posted April 15, 2023 43 minutes ago, mlondon said: Thank you. I made the change, but still get the same error. Then you need to try to set the script to be executable. Open a terminal in the directory with the script and then run sudo chmod +x newdir.py Link to comment
mlondon Posted April 15, 2023 Author Share Posted April 15, 2023 @pixelgeek Did that, error message went away, but script does nothing. Just takes me back to the finder.... Sigh.... Link to comment
sepulchra Posted April 15, 2023 Share Posted April 15, 2023 1 hour ago, mlondon said: Thank you. I made the change, but still get the same error. I did try disabling and re-enabling the Workflow, and even quitting and restarting Alfred, but that didnt help just so i understand, you want to take action on a file or files and then move them to a new folder you create within alfred? is that accurate? Link to comment
mlondon Posted April 15, 2023 Author Share Posted April 15, 2023 1 minute ago, sepulchra said: just so i understand, you want to take action on a file or files and then move them to a new folder you create within alfred? is that accurate? @sepulchra Yes ! Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 @Stephen_C do you have any idea of how to accomplish this with automation tasks? I was puzzling over it last night. Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 @sepulchra it's something like combining my Move files workflow with the New Folder workflow you mentioned. The Move files workflow passes out the full path (including the file name) at the end so it's certainly technically possible to link them. I was thinking about this earlier and it seems to me the problem is not knowing how/where/when the OP expects to be creating the new folder. For example: Are files to be moved to an existing folder in which the new folder is to be created? Is the new folder to be created somewhere (where?) first and the files then moved to it? The first option is quite easy: you can simply use both of my workflows sequentially (i.e., without bothering to link them)—which is what I invariably do. However, without knowing more about the OP's personal workflow (i.e., in the general, rather than the Alfred, sense) it's rather difficult to be of more help I think. Stephen Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 I'm pretty sure it is the latter. Create a folder while using alfred's file navigation and then have a file moved there. Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 15 hours ago, mlondon said: Thank you, but these are both too complex and don't really address my need. I didn't really understand this because I thought my New folder workflow was almost spot on for what the OP needs. All the OP has to do is to move the files and then select them and use that workflow to create the new folder and move the files to it. It's hardly "complex” to my mind. Stephen Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 (edited) I think the issue here is staying within alfred's file navigation. That is why my mind went to using the file buffer object but regardless there is the step of storing the files that need to be moved, searching for a path, creating a new folder in that path, and the having the file(s) moved there. I could see it quite useful for users who prefer using alfred's file navigation over finder. I just couldn't sort it last night. Edited April 16, 2023 by sepulchra Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 Let me have another think. I was just writing some further thoughts which were obliterated when I went to read your reply! 😁 Stephen Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 @sepulchra here, on transfer.sh is a very rough working version of a workflow that: prompts for the location in which the new folder is to be located; then prompts for the name of the new folder; then transfers the selected files to the new folder. The basic configuration option allows the user to specify a default location for the new folder. If there's any interest in this I could no doubt improve it (particularly in the prompts)…and, no doubt, spend several hours looking for an icon for it. 😀 Stephen Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 (edited) This doesn't work for the use case when triggered because when I trigger it, it immediately asks for the path of the base path. You can't search for the base path using the alfred's file navigation. You can only type the path out? is that how it works for you? EDIT: now I see you created a default path for the base path. I think the use case here is being able to navigate to any folder in alfred's file navigation and create a new folder. i managed to get it to work by doing the following, which i hope provides inspiration for a more elegant way to do this..... as this relies on the file buffer navigate to file or files via alfred's file navigation and add them to the buffer navigate to folder where you would like to make your new folder use the following action on that folder (it is a combination of your work @Stephen_C and @Floating.Point. https://transfer.sh/A7R5aS/new folder and buffer move.alfredworkflow there has to be a better way. 🐇🕳️ Edited April 16, 2023 by sepulchra Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 The reason it didn't work for you was because the Config. Builder was not exported (which included a baseFolder setting). I've overcome that in the new version by writing a note in the Config. Builder itself so that the full, proper configuration is exported. I couldn't make your version work either! It didn't seem to put anything in the buffer and neither did the basePath variable do anything for me: sorry! Anyway here is a revised version on transfer.sh. I've improved the prompt in the create new folder section to remind the user of where the new folder will be created. The major weakness of these versions (yours and mine) is the inability to include in the workflow itself a file picker to select the folder in which the new folder is to be created. We have to rely on a default in the Config. Builder—which, of course, is OK if the OP always intends to use the same folder in which to create his or her new folder(s). Stephen Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 That makes sense. Would you mind trying the workflow i sent one more time. It requires the files you want to move are already in the buffer. so it is navigate to files via alfred and '⌥+↑' them into the buffer search for the folder you want your new folder in, then run the universal action.... That is why it isn't ideal. That is why as much I wish there was a way to accomplish this task with only automation objects, i don't think there is. Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 12 minutes ago, sepulchra said: It requires the files you want to move are already in the buffer. Sorry, my fault: I'd not appreciated that! However, it still gets itself into a tizzy (to use a technical expression). Delete the link between Create folder path variable… and Pass on new folder path and connect the Debug utility to the former then run the workflow again. You'll see that the filenames are part of the path. When getting the basepath you need to use the Automation Task Get Path Dirname to strip the filename(s) from the passed in path. Stephen Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 24 minutes ago, Stephen_C said: When getting the basepath you need to use the Automation Task Get Path Dirname to strip the filename(s) from the passed in path. Stephen hmmm that is interesting. the file names shouldn't be part of the base path if they are already in the buffer. I'm not seeing that on this end. Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 Sorry, have not looked at it again was I was working on this proof of concept improvement to my original (already amended with your assistance, of course): on transfer.sh again. It's still very much of a kludge for the poor user but I guess any reasonably competent user could add his own frequently used base folders. Stephen Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 Of course, the latest version could be improved by having a number of file picker fields in the Config. Builder allowing the user to select the base folders he might usually need to use—and then populating those folders in the List Filter. Stephen Link to comment
Stephen_C Posted April 16, 2023 Share Posted April 16, 2023 …and that seems to work well. (With apologies for the multiple posts.) Stephen Link to comment
sepulchra Posted April 16, 2023 Share Posted April 16, 2023 @Stephen_C that works well! And you could go a step further and replace your list filter with a file filter, set your file type to folders, and set the scope to whatever you want and you wouldn't be restricted to 3 folders. 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