No needed Automator. Use script and save as application:
set my_Movie to alias "Untitled:Русские фильмы:1990:Заложница (1990.DVDRip-AVC).mkv"
set my_Application to alias "Untitled:VLC.app:"
tell application "Finder"
activate
open my_Movie using my_Application
end tell
NOTE 1: Here Заложница (1990.DVDRip-AVC).mkv is my movie name. Is stored in subfolder 1990 of subfolder Русские фильмы of USB disk Untitled. Put your paths in lines of code 1 and 2, and you can use this script.
NOTE 2: You can play VLC of startup disk and VLC of USB disk at the same time!!!
NOTE 3: Code line 1 is better to replace with set my_Movie to choose file. Then you can choose other movies from USB and from startup disks.
More professional script will be that:
set timeoutSeconds to 2.0
set uiScript to "set my_Movie to choose file
set my_Application to alias \"Untitled:VLC.app:\"
open my_Movie using my_Application"
my doWithTimeout(uiScript, timeoutSeconds)
on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"Finder\"
activate
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
You can make this script your own (custom) Automator service too. All custom services autosaved by Automator in ~/Library/Services. As this is now real service, you can find it in Services menu with right clicking movies too. Here is steps for creating similar service:
- Open Automator
- In the window that pops up, highlight Service and then hit Choose.
- Now in the Library section on the left, click on Utilities and then find Set Value of Variable. Drag it to the main window on the right.
- In the Variable dropdown, choose New variable… and call it original_Movies
- In the Service receives selected choose Movie files
- Set the in dropdown to Finder.app
- Still in the Utilities section of the Library on the left, find Run AppleScript. Drag it to the main window under our last step.
Opens shell-script:
on run {input, parameters}
(* Your script goes here *)
return input
end run
- Replace (* Your script goes here *) with our script lines:
set timeoutSeconds to 2.0
set uiScript to "set my_Movie to choose file
set my_Application to alias \"Untitled:VLC.app:\"
open my_Movie using my_Application"
my doWithTimeout(uiScript, timeoutSeconds)
- After the sentence end run leave blank line and add our entire handler doWithTimeout:
on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"Finder\"
activate
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
10}: Go to File > Save and give your new service a name. I’ll call mine USB_VLC_Player.
You have just created a Service. This means that if you right-click anybody movie, you can see service USB_VLC_Player, choose it and choose anybody other movie for playing with VLC on USB .
Of course, whenever the USB currently isn’t mounted, subroutine doWithTimeout will throw error with message and stop execution.
I prepared ready workflow. You can download it from Here (clickable reference from DropBox)
Open workflow and edit only рath to your own USB device VLC player (replace only Untitled:VLC.app: with your own path). Then move workflow to folder ~Library/Services.
You can define exactly path to your own USB device VLC player by running in Script Editor this simple code:
set myVLC_Path to choose file
Connect USB, run code, click USB icon, find VLC, choose it and copy from Results window the path {you need here only the piece between quotes)
For example, my result was that:
alias “Untitled:VLC.app:”
As you can see, I had copy only bold here text. This is so as not to confuse you with escaping quotes nested in other quotes. That’s all.