Jump to content
nonickfx

Error in Workflow to move multiple files

Recommended Posts

Hi everyone,

 

I am trying to set up a very simple workflow: 

 

  1. Select one to n items in Finder
  2. Fire up the Alfred dialogue with file actions
  3. Automatically select the "move to" file action
  4. Type in the folder I want to move files to
  5. Files are moved

 

What I have so far: 

 

image.thumb.png.284ee170c2a91b1d8902d69696692fad.png

 

This works perfectly, but only for ONE file. i.e. if I select multiple files, only one shows up in Alfred.

 

 

image.thumb.png.f2eee35654bdc1e0ff1c4dab52b620c3.png

 

And this works for multiple files (I defined ^+SHIFT + < as File Action trigger), but it doesn't register cmd+8 for some reason. I.e. I get to the file actions dialogue but would have to hit cmd+8 myself. 

 

Can anyone help? 

 

Thanks!

Share this post


Link to post

Yes, I'm aware of that. However, this hotkey requires you to first activate it and THEN press "cmd+6" to get to the "move to" dialogue. I'd like to be able to do BOTH with one hotkey. Thanks

Share this post


Link to post
1 minute ago, nonickfx said:

However, this hotkey requires you to first activate it and THEN press "cmd+6" to get to the "move to" dialogue

 

That isn't going to work. Your workflow has ⌘8. Now you're pressing ⌘6. You can't hardcode a Hotkey that keeps changing.

 

You'd be better off using Alfred's AppleScript API to action the files, type "move to" in the query box, then simulate ↩.

Share this post


Link to post

The problem is not that the hotkey is changing, I can hardcode ⌘8 and it would be enough for me. The problem is that I can't find a way to select multiple files and then trigger the File Action list AND the Move-to action. Is there any way to do this?

 

Regarding your solution: I didn't quite understand how I'd do it. Can you please elaborate a bit? 

 

Thanks!

Share this post


Link to post

tell application "Finder" to set selList to selection as alias list

 

if selList is not equal to {} then

    tell application "Alfred 3" to action selList

    tell application "System Events"

        keystroke "Move to"

        key code 36 -- Return

    end tell

end if

Share this post


Link to post

Wow, works exactly as I wanted, thanks a lot!!!

 

Just to make sure: I am connecting the hotkey to "Run Script" and set it to "usr/bin/osascript" and "with input as argv" , correct? (sorry, I'm a total Alfred newbie).

 

p.s. enjoy your beer, just sent you one ? ?

Share this post


Link to post

Yup, that's right. The input doesn't matter, though, as the script gets the files directly from Finder.

 

Thanks very much for the beer money! I'll get a couple of bottles to enjoy while France destroys Germany tonight :) 

Share this post


Link to post

Hi everyone,

 

so after an update to Catalina the following script doesn't work anymore: 

 

tell application "Finder" to set selList to selection as alias list

 

if selList is not equal to {} then

    tell application "Alfred 3" to action selList

    tell application "System Events"

        keystroke "Move to"

        key code 36 -- Return

    end tell

end if

 

Can anyone help? I can't figure out what's wrong :(

 

Thanks!!

Share this post


Link to post
tell application "Finder" to set selList to selection as alias list
     tell application "System Events"
        key code 16 using {command down, shift down}
	    delay 0.2
	    keystroke "Move to"
	    key code 36
    end tell

here's my current workaround. Assumes that you have the combination "shift + cmd + z" to trigger alfred action on a set of files. any ideas how to avoid using the "delay" function (does not seem good coding style to me). 

Share this post


Link to post
54 minutes ago, nonickfx said:

the combination "shift + cmd + z"

 

key code 16 maps to the physical key, so it's Z on your QWERTZ keyboard, but Y on a QWERTY. keystroke "z" using {command down, shift down} is more portable.

 

39 minutes ago, nonickfx said:

any ideas how to avoid using the "delay" function (does not seem good coding style to me).

 

It's not really possible, AFAIK.

 

It's not good coding style, but you don't have much choice when you're just blindly firing key presses an at application. That's why it's a last resort for automating apps.

 

With "regular" applications, you can wait until that application is frontmost, but that doesn't work with Alfred because it is never the frontmost app.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...