do shell script "TIME=`date \"+%Y-%m-%d_%H.%M.%S\"` # TIME is a variable such as 2006-12-25_01.37.56 for 1:37:56 am # on December 25th 2006 # This should almost certainly be unique # if you want to change the filename format, # do so here. Also note, you can change the format from PNG # using the -t flag to screencapture. If you do that # you should change the file extension here. # # NOTE: it would seem that you would need to use $HOME/Desktop/ # somewhere, but if you do, you will get errors, so don't FILENAME=\"Screenshot $TIME.png\" # This is where files will be moved to TARGET_DIR=\"$HOME/Pictures\" # Line 1: Like cmd+shift+4, offer a crosshairs to select what will be captured # and save it as a PNG # Line 2: The file is, by default, saved to the Desktop # but we move it to the TARGET_DIR as defined above # we use mv -n to NOT overwrite existing files, which should never # exist, but you never know # Line 3: Open the file in Preview # NOTE: If you want to have it opened in a different app, change that here # Or if you don't want it to open at all # delete the 3rd line and the && at the end of Line 2 /usr/sbin/screencapture -tpng -i \"$FILENAME\" && /bin/mv -n \"$FILENAME\" \"$TARGET_DIR/\" && /usr/bin/open -a Preview \"$TARGET_DIR\"/\"$FILENAME\" "