Jump to content

How to copy a file to clipboard from a workflow?


Recommended Posts

Posted

Hi folks,

I'm developing a custom workflow. After lots of searching around, I don't find a way to copy the chained file to the clipboard. I've found "Save image to clipboard" in Alfred 5, but I want to copy any file given. Alfred file actions has it, but I don't find any workflow action for that.

 

Any help is appreciated.

 

 

1804111053_Screenshot2022-10-24at17_05_36.thumb.png.7f6fe1825f60397af64b7511aa1a94f4.png

Posted

Welcome @Usman,

 

You can’t just copy any random file to the clipboard. Well, you can¹, but it’ll just be a bunch of data with no guarantee of being accurately pasted. That’s why copying image data is a specific action, it’s done properly to accommodate the input.


Lest this be an XY problem, please describe what you want to do instead of how you think it could be accomplished.



¹ Use a Run Script Action with default actions and code pbcopy < "${1}" to copy the contents of whatever file path is given as input.
Posted

Not the same use case but I got around a similar thing by using some AppleScript. Pass in the path&file

157077513_2022-10-29at18_42.png.7fdc439d3f94d2c3ebf0211237a19681.png

 

Hope it helps in your use case

Posted (edited)

@Pearcen, your thing works great, thank you! I just can't figure out why it fails randomly for some files. I can't find a pattern for the failed files. Attached is a screenshot that shows the failed files with a red exclamation. Do you've any clue?

 

 

image.png

Edited by Usman
Posted

The pattern is that the failed files for some reason have a 0 at the end, after the extension. And they’re failing because (likely) they don’t exist. Question is why is the 0 being appended in the first place.

Posted

@vitor that 0 is mysterious. I think the app where I'm pasting is causing this. I've debugged and there is no 0 in the pasted path. Other apps I tried paste these failing files as plain text path(without the 0) and works properly with files that worked here.

Posted

@usman Glad it is 'sort of' working for you.

Think we'll need to see the workflow to understand what could be happening here with those 0 files.

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