Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to have the file path of a screenshot to be available in the clipboard to paste it directly into some text. Greenshot on Windows can do this in just one keyboard shortcut simultaneously taking the screenshot and putting its file path into the clipboard. How can this be done in Mac?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can assign a shortcut to a script like this:

f=~/Desktop/$(date +%Y%m%d%H%M%S).png
screencapture -i $f
osascript -e 'set the clipboard to POSIX file "'$f'"'

One way to do that is to create a service in Automator:

Then give the service a keyboard shortcut from System Preferences.

If you just want to copy the path as text, replace the last line with printf %s $f | pbcopy.

share|improve this answer
1  
What is the benefit of using AppleScript to set the clipboard? Is the result not the same as pbcopy anyway? –  patrix Jan 4 at 10:15
1  
@patrix pbcopy flattens complex objects into the clipboard as text by default. AppleScript is better for more general purpose pasting where the object could be interpreted as plain text, styled text, several resolution images, etc... hints.macworld.com/article.php?story=20070416161655621 In this case, it's probably moot though. –  bmike Jan 4 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.