0

I'm using a macOS app to create GIFs (called GifFox) but the app does not offer a feature to auto-save to clipboard. However, I can define the location the GIF will be saved to. How can I create an automation that:

  1. listens for new files in this folder and auto-copies them to the clipboard (preferred UX)
  2. that copies the newest file in a folder to the clipboard after I execute a certain shortcut (less optimal).
3
  • Folder action with a shellscript running pbcopy should work.
    – nohillside
    Sep 12 at 14:24
  • @nohillside pbcopy/paste only works with text, (including PostScript and RTF.) Also, I'm not sure that Clipboard stores GIF - it would be converted to TIFF.
    – benwiggy
    Sep 12 at 14:46
  • @benwiggy Ah, right, images are a different beast.
    – nohillside
    Sep 12 at 15:08

1 Answer 1

0

You can save this following AppleScript code in Script Editor.app as "File_To_Clipboard.scpt" (or whatever name you want) to your /Users/your_short_name/Library/Scripts/Folder Action Scripts/ folder.

property theFile : missing value

on adding folder items to theFolder after receiving theNewItems
    --  Called after items have been added to a folder
    
    --  theFolder is a reference to the modified folder
    --  theNewItems is a list of references to the items added to the folder 
    
    set theFile to POSIX path of theNewItems
    set the clipboard to POSIX file theFile
    
end adding folder items to

Then in Finder, right click the Folder that your GIF files will be saved to and select Folder Actions Setup... then select your new "File_To_Clipboard.scpt" file to attach to that Folder.

Now anytime a file is added to that Folder, that file will be copied to your clipboard

2
  • However, if more than one file is added, this is going to choke. You even gave the variable a name that indicates more than one new item...
    – CJK
    Sep 13 at 21:44
  • Thanks! This worked. Note that I had to create this Scripts/Folder Action Scripts-folder first to put the File_To_Clipboard.scpt-script there. Reading your answer it sounded like this already exists.
    – Moritz W
    Oct 12 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .