I’m working on this script that takes a screen shot every 10 seconds and then puts them all in a hidden folder. I’m using this script to take the picture:
Tell app "System Events"
If UI elements enabled then
key down shift
key down command
key up shift
key up command
The problem is with moving the files into the folder. As many of you know, you use the MV command in terminal to move files. Well, when the computer takes a screen shot, it automatically calls it Picture 1, Picture 2, Picture 3, etc. so in Terminal you need to use this as the file path: ~/Desktop/Picture 1.pdf but in AS, it gives an error for the space after the . I also tried moving the file via Finder using this command:
tell application "Finder"
move "~/Desktop/Picture 1.pdf" to "~/Desktop/Hidden/Picture 1.pdf"
But that didn’t work either. Does anyone have an idea on what command will work to move the file on the desktop to a folder?
How about skipping the ui scripting entirely and just using the command line to screen capture directly to the hidden folder? Using this method you can simply provide your own name without any spaces and also programmatically assign the name so you don’t have to use “Picture 1”, “Picture 2”, etc. Note that this code won’t work for paths with spaces. The ‘-x’ disables the shutter sound, which I assume you probably didn’t want.
set tmpPath to "/Users/jed/Desktop/"
set tmpFile to "test7.pdf"
do shell script ("screencapture -x " & (tmpPath & tmpFile))
There can be spaces set in names using the command line, but it’s a little tricky. I tend to like using Applescript to call command line commands because then I can easily set variables.
All that is needed is the line “quoted form of POSIX path of” and you’re all set!
How about this:
set tmpPath to quoted form of POSIX path of “Volumes:Your Disk:Sub-Folder:Even Better Sub-Folder:”
set tmpFile to “test7.pdf”
do shell script "screencapture -x " & tmpPath & tmpFile