Applescript to open a file in mplayer

Hello,
I've been trying to write an applescript that simply opens a file and the passes the path of that file to mplayer with "do shell script." I can figure out how to make it work by using a select file dialog, but I can't seem to make it work as an application that can actually be used to open files.
The general idea here is that I want to use a terminal program as my default app to open files in Finder. Other suggestions on methods to do this are welcome, too.
I'm aware of the GUI Mplayer OS X, but I'd prefer not to use it.
Thanks in advance!

gh02t wrote:
I want to be able to double click it in Finder and have it open in mplayer.
still don't understand why you need apple script at all for this but it's your call.
I figured that writing an applescript to act as a handler that passed a file from finder to the command line would be the best approach.
that can of course work. let's say you've passed this_file to the script as input.
are you looking for something like this:
set fpath to POSIX path of this_file
do shell script "mplayer "&fpath
sorry, don't know the syntax to invoke mplayer from command line but I assumed it would be "mplayer path/to/file"

Similar Messages

  • Applescript to open multiple files

    I have worked up 2 applescripts
    1. to open a set of files
    2. to position the individual windows ( finder and application)
    The first script does not open all the 4 files at one proces, it should.
    In applescript the first run, opens 2 or 3 of the 4, a second Run will open the remaining, or a 3rd run may be required, to get all 4 files open
    Same with the Applescript saved as an application
    Applscript as per:
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/client/P079/aaa"
      do shell script "open " & PTH
              set bounds of Finder window 1 to {273, 569, 550, 1100}
              set position of Finder window 1 to {6, 44}
    end tell
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/client/P079/folder_a/data_a.fp7"
      do shell script "open " & PTH
    end tell
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/client/P079/folder_b/data_b.fp7"
      do shell script "open " & PTH
    end tell
    tell application "Finder"
      activate
              set PTH to POSIX path of (path to home folder) & "Documents/p1/Office/cs_time/Time_v4/a_user_time.fp7"
      do shell script "open " & PTH
    end tell

    Spoke too soon, its still irregular.
    still requires repeating the Applescript Run to open all 4 ( 1 folder 3 files)
    Something weird with the files. I created a new generic folder and subfolders and files named as below, and this runs fine, all 4 every time. But the real project files, 3 out of four first on first run, and the 4th on the second run.
    I makes a difference too, wrt to the order; changing the folder to the last execution only opens 2 targets on the first run, then the 3rd in the second run, the 4th on the 3rd run... and other variations. Feels like some sort of reset or flush to something is required.
    I tried targetting a different file(s) and same mixed results
    It is not a typo in the paths, subsequent runs open the files
    this with test files/folders as define works every time
    set basePath to POSIX path of (path to home folder) & "Documents/p1/"
    set officePath to basePath & "_CS_Office/cs_time/Time_v4/a_user_time.fp7"
    set clientPath to basePath & "FileMaker/_activeProjects/Client/P079/"
    set DR1 to "aaa"
    set FA to "folder_a/data_a.fp7"
    set FB to "folder_b/data_b.fp7"
    do shell script "open " & clientPath & DR1
    tell application "Finder"
              set bounds of Finder window 1 to {273, 569, 550, 1100}
              set position of Finder window 1 to {6, 44}
    end tell
    do shell script "open " & clientPath & FA
    do shell script "open " & clientPath & FB
    do shell script "open " & officePath

  • Applescript to open various files and add info from filename to the file

    Hi guys,
    first time using this forum...
    and first time trying to do a script for apple...
    I figured out how to do simple things... like open files and stuff to text files...  but don't know where to begin:
    I have a directory datalogs...
    within the directory i have multiple text files that have the following format:
    dataXXYYY_Waf2_7_19_11.csv
    dataXXYYY_Waf3_7_19_13.csv
    dataXXYYY_Waf25_7_19_16.csv
    typically 25 files, but sometimes less
    I would like to be able to take each file within the datalogs folder ...
    Scan the file name and look for the number afer Waf
    The number can be anywhere from (single digit) 1 to 25
    I would like to take that value after Waf  and then append a line in the txt file
    the line I would have to add will be 5 rows down and it shoulld say:
    wafer,1 
    the 1 above is the value that was in the file name....
    i.e.
    for the file
    dataXXYYY_Waf25_7_19_16.csv
    before append the file contains random data ... i.e.
    dummyline1
    dummyline2
    dummyline3
    dummyline4
    dummyline5
    dummyline6
    Then after the script...
    the file will be saved with same name:
    dataXXYYY_Waf25_7_19_16.csv
    and the data should look like:
    dummyline1
    dummyline2
    dummyline3
    dummyline4
    wafer,25
    dummyline5
    dummyline6
    any help will be appreciated
    -thanks

    Copy your source folder - named 'datalogs' to your home directory and run this script by copying into a new AppleScript Editor document and pressing Run. 
    I think I've followed your specification, and there will be other ways to do this, but ask if you have questions.  (I have put comments in the code which should explain some of it!)
    There is no error checking, but I have made copies of the original files in the source directory.  (You can comment out the line "duplicate theFile" by prefixing with "--" when you are sure it's working.
    As always, ensure your data is backed-up before proceeding.
    --starts here
    --sets path to datalogs folder
    set theDirectory to (path to home folder as text) & "datalogs"
    set fileNames to {}
    tell application "Finder"
      --gets all the files in the source directory
              set fileList to files of folder theDirectory
      --iterates through the files
              repeat with theFile in fileList
      --makes a duplicate
      duplicate theFile
      --puts the fileName and fileLocation into records in a list of lists
                        set end of fileNames to {fileName:name of theFile, fileLoc:theFile as alias}
              end repeat
      --iterates thru the files
              repeat with theFile in fileNames
      --gets offset of the string "Waf"
                        set WafOffset to offset of "Waf" in (fileName of theFile)
      --trims the name so that it now starts with the character after "Waf"
                        set fileName to text (WafOffset + 3) thru end of fileName of theFile
      --gets offset of the next underscore
                        set UScoreOffset to offset of "_" in fileName
      --stores the desired number by trimming off the end of the file name
                        set fileNumber to text 1 thru (UScoreOffset - 1) of fileName
      --sets up the text to insert by prefixing with "Wafer," and suffixing with return
                        set insertText to "Wafer," & fileNumber & character id 10
      --opens the file with write permission
                        set FileRef to open for access (fileLoc of theFile) with write permission
      --initialise container
                        set fileContents to ""
      --puts first five lines into container
                        repeat 5 times
                                  set fileContents to fileContents & (read FileRef until character id 10)
                        end repeat
      --adds the new text to the container
                        set fileContents to fileContents & insertText
      --adds the rest of the file to the container
                        set fileContents to fileContents & (read FileRef)
      --effectively empties the file
      set eof FileRef to 0
      --writes contents of the container to the file
      write fileContents to FileRef
      --closes the file
      close access FileRef
              end repeat
    end tell
    --ends here

  • Applescript to open Windows file

    I'me using Parallels to run Windows XP on my MAC. Is it possible to "tell" a Windows application (specifically Excel 2010 as opposed to Excel 2007 which I also have) to open a particular file, or alternatively to "tell" Finder to open my file using Excel 2010?

    but I was hoping that AppleScript could run Excel via Finder
    Assuming you mean the Mac version of Excel - that's trivial
    I know I can do the following but it opens the file in Numbers
    That's because Numbers is the default application for .xls documents. You can change the default application, or you can tell the (Mac) app to open the file:
    tell application "Microsoft Excel"
      open file "path:to:your.xls"
    end tell
    NIn other words - tell the application directly, and don't rely on the Finder. Note that the above is the normal syntax... it might not work with Excel's AppleScript 'implementation', in which case you can still fall back to the Finder:
    tell application "Finder"
      open "path:to:your.xls" using application "Microsoft Excel"
    end tell
    Note that the above all assumes that you're using the Mac version of Excel (not trying to script the Windows version running inside Parallels) and that the Mac can see the .xls file (i.e. it's not buried within the Windows container/disk image - if it is you'll need to move the file to somewhere the Mac can see it before you can open it in a Mac app).

  • Open video file in MPlayer on Ubuntu

    Good day !
    Can your please help me.
    I need to run a video file im MPlayer on Ubuntu via Java
    I make so (in main method):
    Runtime.getRuntime().exec("/usr/bin/mplayer -slave -quiet -idle home/andrew/downloads/play.avi");But nothing happens. I don't know why. Can your please help me in advice ?

    As a start you need to read the 4 sections of [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html] and implement ALL the recommendations. Take particular note of those traps involved in not handling stdout and stderr properly and make sure you wait for the process to complete before exiting the program.

  • Opening a file with MPlayer in Nautilus

    I am running Gnome3 and have mplayer2 installed. I was wondering if its possible to get it so that if I double click a *.mkv or *.avi file in 'Files' then it would be opened with mplayer2.
    If I right click and select 'Open with other application' then mplayer isn't an option.
    Thanks

    You can create a text file in /usr/share/applications(or ~/.local/usr/applacations) and name it MPlayer2.desktop
    Now edit the file and paste:
    [Desktop Entry]
    Type=Application
    Name=MPlayer2 Media Player
    GenericName=Multimedia player
    Comment=Play movies and songs
    Icon=mplayer
    TryExec=mplayer2
    Exec=mplayer2
    Terminal=false
    NoDisplay=true
    Categories=GTK;AudioVideo;Audio;Video;Player;TV;
    MimeType=application/ogg;application/x-ogg;application/sdp;application/smil;application/x-smil;application/streamingmedia;application/x-streamingmedia;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/aac;audio/x-aac;audio/m4a;audio/x-m4a;audio/mp1;audio/x-mp1;audio/mp2;audio/x-mp2;audio/mp3;audio/x-mp3;audio/mpeg;audio/x-mpeg;audio/mpegurl;audio/x-mpegurl;audio/mpg;audio/x-mpg;audio/rn-mpeg;audio/scpls;audio/x-scpls;audio/vnd.rn-realaudio;audio/wav;audio/x-pn-windows-pcm;audio/x-realaudio;audio/x-pn-realaudio;audio/x-ms-wma;audio/x-pls;audio/x-wav;video/mpeg;video/x-mpeg;video/x-mpeg2;video/mp4;video/msvideo;video/x-msvideo;video/quicktime;video/vnd.rn-realvideo;video/x-ms-afs;video/x-ms-asf;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvxvideo;video/x-avi;video/x-fli;video/x-flv;video/x-theora;video/x-matroska;
    Name[en_US]=MPlayer2 Media Player
    Now mark it as executable, go to your .mkv file and choose 'open with' you should be able to use MPlayer2 now.

  • Developers I need an applescript that opens documents in excel from a specified folder and saves them as .xlsx from their current .xlsb

    mule13470 
    Apr 3, 2014 11:12 AM 
    I tried simply renaming them however it just corrupts the files when I do it like that so I need the applescript to open the files in excel and the save them as .xlsx to test I only need it one folder but if it works I'd like to be able to do it for all documents with .xlsb extentions that are in a huge folder with subfolders that contain a mix of .pdf, .docx, .xlsx and .xlsb. Please Help.
    Applescript Editor, Mac OS X (10.6.8) 
    I have this question too (0) 
    Reply
    Categories: Using OS X MavericksTags: mac, help, finder, excel, applescript_editor
    Level 1 (0 points)
    mule13470
    Re: I need an applescript that opens documents in excel from a specified folder and saves them as .xlsx from their current .xlsbApr 3, 2014 11:19 AM (in response to mule13470) 
    In that huge folder I only need the .xlsb files opened and saved to .xlsx not the others, in case that wasn't clear above.

    In that huge folder I only need the .xlsb files opened and saved to .xlsx not the others, in case that wasn't clear above.

  • I need an applescript that opens documents in excel from a specified folder and saves them as .xlsx from their current .xlsb

    I tried simply renaming them however it just corrupts the files when I do it like that so I need the applescript to open the files in excel and the save them as .xlsx to test I only need it one folder but if it works I'd like to be able to do it for all documents with .xlsb extentions that are in a huge folder with subfolders that contain a mix of .pdf, .docx, .xlsx and .xlsb. Please Help.

    In that huge folder I only need the .xlsb files opened and saved to .xlsx not the others, in case that wasn't clear above.

  • How can I force Firefox to open webm files in a external application like mplayer?

    I want to open webm files from browsing sites (for example tagesschau.de) in mplayer through 'xterm -e' where I set a specific placement of the window and other parameters. Setting media.webm.enabled to false only disabled internal player, but does not open any option under Preferences -> File Types. Playing with advanced configuration I tried creating media.webm.handler{,default,application} according to other file type that are set to external applications. No luck. I have set mp4 files to use the same script (with execution permission) and it works exactly as I want.
    Script:
    <pre><nowiki>#!/bin/bash
    FILENAME="`basename "$@"`"
    xterm -fs 24 -bg black -fg white -title "$FILENAME" -geometry 96x8 -e "echo \"$FILENAME\"'\\nfrom\\n'\"$@\" && \
    mplayer -geometry 100%:100% -vf dsize=400:-3 -volume 80 \"$@\" "</nowiki></pre>
    The script itself works when I feed it a webm url (or any other media for that fact).
    Linux 3.9.9-1-ARCH x86_64 GNU/Linux

    I don't know about linux cos i'm win user. But you may start with disabling internal webm support. about:config -> media.webm and then I think you should install greasemonkey addon and custom script for playing content in 3rd partys players. (At least that is my configuration. I'm using VLC for youtube)

  • ICal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed on alert.

    iCal failing to run applescripts: The 'Open' button does not change to 'Run', and the script file is opened but not executed.

    Calendar (not called iCal anymore) does not include that capability any longer, apparently.  What you have to do now is go to Automator and create a Calendar Alert action.  You can add a Run AppleScript object to the action and paste in your script there, then when you save it, it will become available as a choice in the alert menu in Calendar.

  • Applescript photoshop open file delay

    Hi,
    I have a problem with photoshop and applescript. When I run the following simple applescript which opens a document and saves it in a location:
    tell application "Adobe Photoshop CS3"
    open picpathalias
    -- delay 10 -- quite a long delay is needed
    save current document in file regpicpath as JPEG
    end tell
    I often receive the following error:
    Adobe Photoshop CS3 got an error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop.
    - The object current document is not currently available.
    It seems there is a race between the open cmd and the save cmd. This most often happens when photoshop is not yet an open application. It almost never happens when photoshop is already open. Is there a programmatic way to make open block until the document is available?
    Thanks.
    -yang

    To clarify, I would like to avoid a soln that uses an arbitrary timeout delay if possible.

  • Cannot open a file by Applescript

    With Photoshop CS6, I am getting an error trying to open a file. This breaks a few of my scripts which continue to work with CS5.
    This code, copied almost exactly from the CS6 Applescript Reference, returns
    error "Adobe Photoshop CS6 got an error: File some object wasn’t found." number -43
    Passing myFilePath to Finder works perfectly fine to open the alias.
    tell application "Adobe Photoshop CS6"
              set myFilePath to alias "Macintosh HD:Users:ats:Downloads:Photoshop-CS6-AppleScript-Ref.pdf"
              tell application "Finder"
      open myFilePath
              end tell
      open myFilePath as PDF with options {class:PDF open options, height:pixels 100, width:pixels 200, mode:RGB, resolution:72, use antialias:true, page:1, constrain proportions:false}
    end tell

    Yeah that looks better… I don't have CS6 so I wasn't able to check… With CS5 things changed with using File & Alias I wasn't too sure if it had been swapped back… Untested…
    set myFilePath to "Macintosh HD:Users:ats:Downloads:Photoshop-CS6-AppleScript-Ref.pdf" -- a string
    -- then coerce inside tell app block
    tell application "Adobe Photoshop CS5"
      open alias myFilePath as PDF with options ¬
                        {class:PDF open options, height:pixels 100, width:pixels 200, mode:RGB, resolution:72, use antialias:true, page:1, constrain proportions:false}
    end tell
    -- ditto here
    tell application "Adobe Photoshop CS5"
      open file myFilePath as PDF with options ¬
                        {class:PDF open options, height:pixels 100, width:pixels 200, mode:RGB, resolution:72, use antialias:true, page:1, constrain proportions:false}
    end tell

  • How to open alias files with applescript in Powerpoint?

    I would like to do something like this:
    set F to choose folder
    tell application "Finder" to set P to (files of entire contents of F whose name extension is "ppt")
    repeat with oneFile in P
              tell application "Microsoft PowerPoint"
      activate
                        open (oneFile as alias)
              end tell
    end  tell
    It works fine if all files are regular files.
    But I want/need it to work also, if some of the files are aliases (icon has the little pointer in Finder).
    Could some kind soul explain to me what I would have to do?
    TIA.
    Gabriel.

    Are you saying this doesn't work? Generally applications don't/shouldn't care about whether you pass them an actual file or an alias.
    In either case, it's not hard to dereference the alias back to the original file:
    set F to choose folder
    tell application "Finder" to set P to (files of entire contents of F whose name extension is "ppt")
    repeat with oneFile in P
              if class of oneFile is alias file then
                        tell application "Finder" to set oneFile to (original item of oneFile)
              end if
      open oneFile
    end repeat
    Note that I've just specified 'open oneFile' rather than targetting PowerPoint directly - there's no need to target PowerPoint if it's the default application for .ppt files. However, there's no problem telling PowerPoint to open the file if you prefer.

  • How to close all files that an Applescript has opened?

    I'm writing a script with multiple "open for access file ... with write permission" commands. It writes to various of them, making csv databases as it works its way through analyzing an xml file (generated by other software), then closes them all at the end.
    My problem is that, if the script crashes or I have to halt it before it gets to the "close" commands at the end, the files are left open. This causes an obvious error when next running the script after making adjustments.
    How can I ensure that those files are always closed? At present I'm doing it by quitting and re-starting Script Editor, which leaves me disoriented in the code.
    Is there a generic close command that I can insert at the start of the script, for example?

    Use this handler to open files.  It tries to open the file, and if it gets error -49 (file already open) it closes the file and reopens it.  It returns a file pointer to the open file, which you can use to refer to the file later.
    on openAFile(filePath, writable)
              try
                        set fp to open for access filePath write permission writable
              on error errstr number errNum
                        if errNum = -49 then
                                  close access filePath
                                  set fp to open for access filePath write permission writable
                        else
                                  display dialog errstr
                                  return false
                        end if
              end try
              return fp
    end openAFile
    set pointer to openAFile("/path/to/some/file", true)
    set fileContents to read pointer
    --close access pointer

  • PSCS3 Mac: Can't get Applescript to open "desktop:folder:file.jpg"

    I have Photoshop CS3 and am scripting a lengthy workflow, and part of it requires that I get Metadata out of files using Photoshop.
    I can not get Photoshop to open a file. Once I have the file open, I can get the metadata out using UI scripting, but I have tried numerous approaches to open files and it has me stumped.
    I am making it as a function that I can call from the main script which compares a new list of files with a list that is a few minutes old to determine which files are new and repeats with each file in the list. So the function will be getting a file name or a path.
    Any help would be greatly appreciated!
    Brian

    I got it! It needs to be an alias class path, and I had to concatenate the path incrementally before finally the whole path is in one variable I could coerce into an alias.
    Of course, this is just one segment of the whole workflow.
    tell application "Finder"
    activate
    set fileList to name of (items of folder "to gallery" of desktop)
    repeat
    set newFileList to name of (items of folder "to gallery" of desktop)
    if length of newFileList > 0 then
    repeat with thisFile in newFileList
    if thisFile is in fileList then
    else
    my PSInfoGalAdd(thisFile)
    end if
    end repeat
    set fileList to newFileList
    end if
    delay 30 --This will eventually be 4 minutes
    end repeat
    end tell
    on PSInfoGalAdd(thisFile)
    tell application "Adobe Photoshop CS3"
    activate
    set desktopPath to path to desktop
    set toGalPath to desktopPath & "to gallery:" as string
    set wholePath to toGalPath & thisFile
    set openIt to wholePath as alias
    open openIt
    tell application "System Events"
    tell process "Adobe Photoshop CS3"
    key code 34 using {command down, option down, shift down} --File info window
    delay 4
    repeat 12 times
    key code 125 --down arrow to Origin
    delay 0.2
    end repeat
    repeat 5 times
    key code 48 --tab to credit
    delay 0.2
    end repeat
    key code 8 using command down --copy
    delay 0.3
    set credit to the clipboard
    repeat 3 times
    key code 48 --tab to instructions
    delay 0.2
    end repeat
    key code 0 using command down --select all
    delay 0.3
    key code 8 using command down --copy
    delay 0.3
    set headline to the clipboard
    key code 48 --tab to transmission reference
    key code 0 using command down --select all
    delay 0.3
    key code 8 using command down --copy
    delay 0.3
    set body to the clipboard
    key code 48 --tab
    key code 36 --return key to dismiss info window
    end tell
    end tell
    end tell
    end PSInfoGalAdd

Maybe you are looking for

  • Pop up menu

    I have a class that extends JPasswordField. no i need a thing like a pop up menu like in the windows when you have caps lock on i come up to tell you this way my users know that caps is active. i have done all of the back door stuff and at the moment

  • Need to get bookmarks off of a harddrive from a pc that no longer works, have the drive ina caddy

    need to retrieve bookmarks from a harddrive from a pc that no longer works, the drive is now in a caddy atached to this pc ,and i can view the data, but dont know the location of firefox bookmarks

  • Icon theme not loaded correctly

    Hey there, i don't know how to fix this one, maybe a specialist in icons and icon themes know the answer: Well, im using the PNG version of Snowish icons at the moment. As you can see here http://img155.imageshack.us/my.php?imag - scrmo2.png, the ico

  • Safe Mode downright refuses to load so i can reset it.

    i can not get the safe mode reset box to appear period. I have just your standard ole firefox latest edition. I can get into the safe mode version of firefox but the box to reset stuff does not show up like all the help sites say it should, and there

  • Oracle 10 Connection Cache (another question)

    Hi all, We have a large web app which currently uses JRun connection pooling. This is causing some problems so we'd like to try the Oracle Connection Cache mechanism. The thing is, each time a client gets a database connection, it runs a connection f