开发者

Automator mac "Take Screenshot" issue

I need to automate a screenshot task, so I thought why not use automator? I found the "Take Screenshot" Action and started to play with it. The problem is is that is开发者_C百科 sets the file name and when the workflow is ran again it overwrites the prior screenshot. I tried selecting this and renaming it but it wont work. Essentially what I want is the normal function of command + shift + 3 where it will date-stamp it or something, anything but overwrite!! Any ideas?


I managed to use screencapture and date to do something similar:

fdate=$(date +"$m$d$Y") #I formatted time as mmddyyyy. You can use other formats, add dashes, etc.
screencapture -iW ~/$fdate.png   #outputs file at ~/mmddyyyy.png

or something like that. You could wrap this into a shell workflow, or put it in the popular wrapper for OSX, Platypus. I'd seriously like to know how to do that, since I've never been able to understand Platypus.


I took the answer from @user8259 and made it more like the built-in screen capture that you normally see:

# We'll use the default format for the time-stamp
# This could be improved to be more like the Mac's built-in
# screen-shot with yyyy-mm-dd at hh.mm.ss AM/PM
# you would just have to figure out the date-time formatting
# in this shell script.
theTime=`date`

# create the file name for the screen-shot
theFileName="$HOME/Desktop/Screenshot $theTime.png"

#outputs file on the Desktop with a timestamp
screencapture "${theFileName}"

My version of the code includes a time-stamp in addition to the date-stamp to make it less likely that a screen-shot will overwrite a previous screen shot.

You can add this code to an Automator action called the "Run Shell Script" action instead of using the "Take Screenshot" action.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜