2

My movie collection has this setup:

  • a folder "Movies/Covers" with the images of the covers (jpg files)
  • a folder "Movies/Videos" with the corresponding video files (mostly mp4 files)

The files in both folders have the same base name.

I would like to be able to right click an image in the covers folder, select the service "open video" and open the corresponding video file in the videos folder with the VLC player.

I'm very new to Automator and initially I tried to do this for files in the same folder with this workflow:

But it doesn't work because the file renamed from xxx.jpg to xxx.mp4 opened by VLC is still an image.

Anyone could help me?

PS: In the past I used to add the cover to the video files as icons and choose the movie in the finder grid view, but this has led to problems after updating the operating system on several occasions.

  • Welcome to the site - Space1815. Be sure to accept and vote up good answers - that’s the best way to thank people for helping. (And of course looking down the line to answer questions you know when you find them) – bmike Sep 16 '19 at 16:13
1

You don't want to rename the file, just use a new folder path in order to look up a matching file. Automator doesn't include default actions for stuff like that, so you are looking at using a third party action or a script, or doing that part yourself.

For an AppleScript solution, create a new service/quick action workflow that receives files or folders in the Finder, and add a Run AppleScript action, replacing the default script with the following:

on run {input, parameters} -- match name of an input item to a videoFolder item
    set videoFolder to ((path to home folder) as text) & "Movies:Videos:" -- the HFS folder path containing matching video files
    repeat with anItem in the input -- return the first match
        set {theName, theExtension} to getNamePieces from anItem
        tell application "Finder"
            set matches to (files of folder videoFolder whose name starts with theName) -- match any extension
            if matches is not {} then return (first item of matches) as alias
        end tell
    end repeat
    return missing value -- no match
end run

to getNamePieces from someItem -- get name and extension from a file item
    tell application "System Events" to tell disk item (someItem as text)
        set {theName, theExtension} to {name, name extension}
    end tell
    if theExtension is not "" then
        set theName to text 1 thru -((count theExtension) + 2) of theName -- the name part
        set theExtension to "." & theExtension
    end if
    return {theName, theExtension}
end getNamePieces

...then finish up by adding an Open Finder Items action, and save the workflow.

|improve this answer|||||
  • Why not use movies folder instead of home folder' so all you need is & "Videos:"` Also since 99% is already scripted, why add an Open Finder Items action when you can just replace return with open in if matches is not {} then return (first item of matches) and get rid of the return missing value -- no match as it will not be needed as the Run AppleScript action is all that's really needed. KISS – user3439894 Sep 15 '19 at 22:29
  • I usually try to keep options open, for example if the particular files are somewhere other than one of the standard folders, it becomes desirable to handle multiple files or use other actions on the script result. I suppose it is a style kind of thing. – red_menace Sep 15 '19 at 23:34

You must log in to answer this question.

Not the answer you're looking for?Browse other questions tagged .