Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Can I do this with Applescript?

I have no knowledge at all of Applescript, but I'm hoping someone can tell me what to do with it.


I am working on making an .srt file for film subtitles. I've done some manually and so I know what to do, but I have some steps I do often that are just a pain and I'd like to automate those steps. This is what I do:


1. Edit or add to the file (using Textedit)


2. Save it (maybe this step isn't necessary with the auto-save, but I am often making a small change and quickly going back to the video to load it in. I don't know if the auto save would also save it quickly enough to skip forcing the save with command-S.


3. Go to the video (using VLC for this). It's always the same video and is still open.


4. Go to the menu for subtitles and select "Open file".


5. Open the .srt file I edited (this is also always the same file).


6. Rewind or otherwise change the starting point to see if my changes worked and appear at the right time.


This process is done over and over. What I'd like to do is combine steps 2 through 5 into one script or macro.


Obviously item 1 must be done manually and I assume I wouldn't be able to have a macro take the present position of the video and automatically have it start 20 seconds earlier, but if I can get help with the rest, it will really speed up my work!


Or maybe there is another option besides Applescript?

Posted on Dec 31, 2012 11:16 PM

Reply
Question marked as Best reply

Posted on Jan 1, 2013 4:01 PM

AppleScript

Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X, Third Edition the book


AppleScript Language Guide pdf download the pdf file


Intro to applescript with sending an email
http://mac.appstorm.net/how-to/applescript/the-ultimate-beginners-guide-to-apple script/

4 replies

Jan 1, 2013 9:29 PM in response to rccharles

Well, in 6 years, I've only had a need for Applescript once. It isn't like when I used to work heavily in Excel on a PC and was making pretty complicated operations with it's basic language all the time. If I was, I'd be studying for lots of usage, but that's not my situation. I just need one script - or an alternative solution - for a temporary project.


I'll save your references in case I ever do get involved more with this, but right now, it seems as if that learning process would cancel the advantage of any macro that would result.

Jan 1, 2013 10:09 PM in response to dbk9999

I haven't tried this, but most of it doesn't seem like a big deal:


2. Save it (maybe this step isn't necessary with the auto-save, but I am often making a small change and quickly going back to the video to load it in. I don't know if the auto save would also save it quickly enough to skip forcing the save with command-S.


tell application "TextEdit"


savedocument 1

end tell

3. Go to the video (using VLC for this). It's always the same video and is still open.


tell application "VLC" to activate

4. Go to the menu for subtitles and select "Open file".


Urgh. UI actions? icky (see #5 below)


5. Open the .srt file I edited (this is also always the same file).


tell application "VLC" to open file "/path/to/the.srt"


(note this may or may not work depending on whether VLC will accept opening a .srt without associating it with a particular window... needs testing. If it doesn't work you may need to resort to Ui scripting)

Note that you can also make the script more robust/flexible by not hard-coding the path but asking TextEdit for the current document's path:


tell application "TextEdit"

set thePath to path of document 1

end tell


tell application "VLC"


activate


openfilethePath

end tell



6. Rewind or otherwise change the starting point to see if my changes worked and appear at the right time.


This one I can't fix - at least, I can't see any way in the VLC dictionary to control playback.

Jan 1, 2013 10:41 PM in response to Camelot

Great. Probably won't get to test it right away - working on another project at the moment - but it looks logical to me! Thanks a lot. If it works, I'll come back and mark it as "solved".


Oh, while I'm using VLC at the moment, I'm not locked into that. Any video player that would let me select an .srt file would be fine so if you know of one that would let Applescript take the existing time point for the video and back it up a set number of seconds, I'd love to know (and how to do that).


Thanks again.

Can I do this with Applescript?

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