Applescript to record webcam video

Hi,


I am new to applescripts and I am trying to write a script to record from webcam for say X seconds. I am using the script below but I am getting an error that I do not have permission to save this file to Desktop. How can I avoid this error? Secondly how can I save the file with Date and Time stamp appended in the name of the file.


Thanks a lot in advance, this is my first post in the community 🙂


tellapplication "QuickTime Player"
  set newMovieRecording to new movie recording

  tell newMovieRecording
  start
  delay 5
  pause
  save newMovieRecording in "/users/rohitbhutani/desktop/movie.mov"
  stop
  close newMovieRecording
  end tell

MacBook Air, OS X Mavericks (10.9.5)

Posted on Jul 15, 2016 7:22 AM

Reply
9 replies

Jul 15, 2016 8:41 AM in response to rbhutani

Hi rbhutani,


First of all, you should have written

savenewMovieRecordinginPOSIX file "/Users/rohitbhutani/Desktop/movie.mov"

instead of

savenewMovieRecordingin "/Users/rohitbhutani/Desktop/movie.mov"

Next, in order to save the file with Date and Time stamp appended in the name of the file, you could proceed as follows:


set theCurrentDate to current date

set dateTime to short date string of theCurrentDate & space & time string of theCurrentDate

set theFilePath to "/Users/rohitbhutani/Desktop/movie " & dateTime & ".mov"


tell application "QuickTime Player"

set newMovieRecording to new movie recording

tell newMovieRecording

start

delay 5

pause

savenewMovieRecordinginPOSIX filetheFilePath

stop

closenewMovieRecording

end tell

end tell

Jul 15, 2016 8:55 AM in response to rbhutani

First, it was by mistake that I posted my previous message under a very old username of mine.


I have tested the script with the French Canadian version of OS X where the datetime variable was in the form "16-07-15 11:49:49", without any slash.


Does the script work if you temporarily set dateTime to any short text string? For example: set dateTime to "today"

Jul 15, 2016 9:08 AM in response to rbhutani

The following should do the trick:


set theCurrentDate to current date

set dateTime to short date string of theCurrentDate & space & time string of theCurrentDate

set P to offsetof "/" indateTime

set dateTime to text 1 through (P - 1) of dateTime & "-" & text (P + 1) through -1 of dateTime

set P to offsetof "/" indateTime

set dateTime to text 1 through (P - 1) of dateTime & "-" & text (P + 1) through -1 of dateTime

set theFilePath to "/Users/rohitbhutani/Desktop/movie " & dateTime & ".mov"


tell application "QuickTime Player"

set newMovieRecording to new movie recording

tell newMovieRecording

start

delay 5

pause

savenewMovieRecordinginPOSIX filetheFilePath

stop

closenewMovieRecording

end tell

end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript to record webcam video

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.