Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.6: Rename screenshots with Automator and AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Rename screenshots with Automator and AppleScript
Authored by: homeshire on Dec 09, '09 10:31:19AM

Oh my --
at least I'm having fun. I just don't know what's going on. did not understand the part concerning no space between -t and extension because I could find no such spot in the script.

so instead I tried your idea about using the variable captureformat rather than plain format. that did the trick!!! sortof.

now when I run the script choosing the desktop folder as destination, my capture appears momentarily, then poofs into the aether. as well, the title is .png , not the extension -- the extension is gibberish that was different gibberish on three different captures.

then I tried it with a different destination. it stayed put, and even moved to my desktop without poofing. but it turned up as a plain text file of 2.2 mb size. so I changed the extension to .png and it opened just fine.

I'll paste the code I've used exactly so you can peruse it. maybe I'm just not seeing something:

tell me to set thePath to (choose folder)
set thePath to (POSIX path of thePath)
set captureformat to "png"
set defAns to "." & (captureformat) as string
tell me to display dialog thePath default answer defAns buttons {"Cancel", "OK "} default button 2
copy the result as list to {text_returned, button_pressed}
tell me to (display dialog "set Delay" default answer 2 buttons {"Cancel", "OK "} default button 2)
copy the result as list to {text_returned2, button_pressed2}
set Delay_ to text_returned2 as number
delay Delay_
set doit to do shell script ("screencapture -t" & (captureformat) & space & (POSIX path of thePath) & text_returned as string)

btw --10.5.8 on a g5 iMac

thanks for your attention mh

p.s. I too am using spark 3.0b9

p.p.s. mh -- if I delete the leading period before png in the script which is defined as the start of the variable defAns, the file does not poof when the script is run. it stays on the desktop as a plain file with no extension - with the title png. if I manually add the extension, it transforms into a png that opens as expected.

Edited on Dec 09, '09 10:42:45AM by homeshire



[ Reply to This | # ]
10.6: Rename screenshots with Automator and AppleScript
Authored by: mark hunte on Dec 09, '09 11:57:20AM
The fact that the format thing worked points to you running additions,
There maybe more running that are also a problem.. I never use them, but I think you can check in the Prefs, under plugins. As for the disappearing, do you have some sort of tidy up app, script or folder action running to put file in folders by kind.

The -t part is -t" & captureformat , no space after the t

Also Here is a slightly better script which will take care of any file names you use with spaces in them.

Look at the Event log, to see what the script is doing. You should see something like:
do shell script "screencapture -tpng '/Users/userName/Desktop/Safe 1.png'"


tell me to set thePath to (choose folder)
set thePath to (POSIX path of thePath)
set captureformat to "png"
set defAns to "." & captureformat as string
tell me to display dialog thePath default answer defAns buttons {"Cancel", "OK "} default button 2
copy the result as list to {text_returned, button_pressed}
tell me to (display dialog "set Delay" default answer 2 buttons {"Cancel", "OK "} default button 2)
copy the result as list to {text_returned2, button_pressed2}
set Delay_ to text_returned2 as number
delay Delay_
set apath to (POSIX path of thePath) & text_returned as string
set doit to do shell script ("screencapture -t" & captureformat & space & quoted form of apath as string) 
log ("screencapture -t" & captureformat & space & quoted form of apath as string) 
---
mh


[ Reply to This | # ]