4 Replies Latest reply: Jan 1, 2013 10:41 PM by dbk9999
dbk9999 Level 1 Level 1 (55 points)

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?

  • rccharles Level 5 Level 5 (6,490 points)

    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/

  • dbk9999 Level 1 Level 1 (55 points)

    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.

  • Camelot Level 8 Level 8 (46,400 points)

    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"

      save document 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

      open file thePath

    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.

  • dbk9999 Level 1 Level 1 (55 points)

    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.