Incrementing by one and saving

Hi there,

In my attempt to make an easy solution for taking screenshot and giving a link to people I have designed an Automator action, which at this point is very primitive. Currently it works like this:

  • Takes a screenshot after 3 seconds and saves it to ~/Sites/screenshot.png
  • Runs:
set the clipboard to "http://1.2.3.4/~username/screenshot.png"

That makes it possible for me to quickly paste it to people I’m working with. Of course my real IP address replaces 1.2.3.4, as does my username ~username.

What I would like to do at this point is to make it less primitive by:

  • Make screenshots save to ~/Sites/screenshot1.png and then make it increment by one in the next screenshot, making it ~/Sites/screenshot2.png
  • Makes the URL reflect that.

Hi Fridrik,

To create screen shots with index:

property ss_index : 0

set ss_index to ss_index + 1
set ss_name to “screenshot” & text -5 thru -1 of (“0000” & ss_index) & “.pdf”
set sites_ref to (path to “site”)
set sites_path to POSIX path of sites_ref
set ss_path to quoted form of (sites_path & ss_name)
do shell script "/usr/sbin/screencapture " & ss_path

Did you want to modify the html link to reflect the new name?

Edited: forgot to lace the script in tags again:


property ss_index : 0
--
set ss_index to ss_index + 1
set ss_name to "screenshot" & text -5 thru -1 of ("0000" & ss_index) & ".pdf"
set sites_ref to (path to "site")
set sites_path to POSIX path of sites_ref
set ss_path to quoted form of (sites_path & ss_name)
do shell script "/usr/sbin/screencapture " & ss_path

gl,

Thanks for your excellently quick reply and the great working script.
Yes, being able to get the filename in question to the clipboard would be excellent.

Thanks again, for your helpfulness and for sharing your knowledge :slight_smile:

Hi Fridrik,

To set clipboard to the name:

set the clipboard to ss_name

You could also search the html code for the name of the old screenshot and replace it with the new name instead of using the clipboard.

gl,