How can I paste a screenshot image from clipboard into a folder?

My screenshots go directly to my clipboard, which works for me most of the time, so I'm not trying to change that behavior.

What I want to do is paste said screenshot into a folder of my choosing.

Finder doesn't seem to let me paste my screenshots from my clipboard into folders, so now I'm looking for a workaround that uses as few steps as possible.

The suboptimal Approach: I've found that I can open these images from my clipboard in Preview, but then I have to re-save them to a desired folder, which is too cumbersome to be considered a solution.

What I'm looking for: Something with fewer steps than the above approach. I just need to get the image from my clipboard into a folder of my choosing. If you can do better, you'll save me and others a lot of time.


Solution 1:

I created an automator workflow to solve this problem

Bottom line: the solution allows you to save an image from the clipboard anywhere with one keystroke (you have to show it where to go in the save dialogue, obviously)

The workflow opens preview, creates a new file from the clipboard, and saves the file (opening the save as dialogue). You can then put it wherever you want. Here's the link to a zip with the workflow. To run the workflow, you'll probably need to approve automator with certain permissions (it'll pop up if and ask for approval, so don't worry if you don't run into this problem). Open the zip, then double click the file (make sure there's an image in the clipboard). A new file should open in preview and ask to be saved.

To create a shortcut, just go to 'keyboard' under system preferences > 'shortcuts' > 'services' and setup the shortcut.

Solution 2:

Edit/Re-Write # 2:

My earlier answers were wrong, and while troubleshooting, new (and likely better) answers have been posted. Nevertheless, I've finally got a correct answer, so I'm going to post it. I've tested it with screenshots on my 10.15.4 system, and it worked reliably in my (limited) testing. As there were already answers to this question that required only minor adaptation, I relied heavily upon them - this one, and this one in particular, both posted by @CJK.

This answer requires use of the command line. It uses only resources that are native to macOS 10.15.4, and there are no work-arounds offered. Here's what I did:

Start the Terminal app, and then from the shell (zsh) prompt (%) start the editor of your choice to open the ~/.zshrc file in your "home" ($HOME) directory. I've used nano here:

% nano ~/.zshrc

When the editor opens, you may have only an empty file - that's fine. If there is something in the file, just move the insertion point to the end of the file, then copy and paste the following text into the editor:

function pss () {
    folder=$(pwd)
    filename="Screen Shot $(date +%Y-%m-%d\ at\ %H.%M.%S).png"

    if [ $# -ne 0 ]; then
        if [[ -d $1 ]]; then
            if [ "$1" != "." ]; then folder=$1; fi
        else
            a=$(dirname "$1")
            b=$(basename "$1" .png)

            if [ "$b" != "" ]; then filename=$b.png; fi

            if [ "$a" != "." ]; then folder=$a; fi
        fi
    fi

    osascript -e "tell application \"System Events\" to ¬
            write (the clipboard as «class PNGf») to ¬
            (make new file at folder \"$folder\" ¬
            with properties {name:\"$filename\"})"
}

Save the file, and exit the editor. You have now created a shell function named pss (for paste screen shot).

Before you can use this shell function, you'll need to source this change to zsh (a logout/login, or reboot will accomplish the same thing, but this is easier):

% . ~/.zshrc
# OR, ALTERNATIVELY:
% exec zsh

Take a screenshot as you've configured it now - with the output going to the clipboard.

Finally, use the pss function to copy/save the screenshot to the a file in your desired location:

% pss /Users/yourid/yourfolder

A couple of notes:

  1. The filename has been set in the pss function to approximate the default filename used by the system for screenshots. If you wish to change that, modify the following line:
filename="Screen Shot $(date +%Y-%m-%d\ at\ %H.%M.%S).png"
  1. You do not need to always specify the folder location. If you cd to the directory in which you wish to save your screenshot files, you can simply run the pss function without an argument. For example, you wish to save your screenshot files to /Home/user/screenshots:
% cd /Home/user/screenshots
# make your screenshot
% pss
# the screenshot file is created in this (the `pwd`) directory