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
    Commented Sep 12, 2022 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
    Commented Sep 12, 2022 at 14:46
  • @benwiggy Ah, right, images are a different beast.
    – nohillside
    Commented Sep 12, 2022 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

4
  • 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
    Commented Sep 13, 2022 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
    Commented Oct 12, 2022 at 12:02
  • Unfortunately, this just stopped working for me. (14.0 (23A344))
    – Moritz W
    Commented Nov 13, 2023 at 2:36
  • OK, nvm, disabling and re-enabling the folder actions in the "Service" dropdown settings popup fixed this.
    – Moritz W
    Commented Nov 13, 2023 at 3:14

You must log in to answer this question.

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