0

This answer to Play folder with right button with VLC explains how playing all the audio tracks within a folder can be accomplished when using VLC.

I don't want to install VLC, how can I accomplish something similar with iTunes?

1
  • What exactly are you trying to accomplish? Do you want the files to be saved to iTunes and remain there or just play an always changing folder once? If you just want to play it once then iTunes is probably the wrong tool to do so as it will keep the files in its library. The alternative to VLC would be QuickTime here I believe. Commented Jan 27, 2019 at 21:38

1 Answer 1

1

In Automator app, create a new quick action. Select the option “folders” for the item “workflow receives current” and select Finder app as your choice for the application to run this service with.

Next, add an AppleScript action to your workflow and insert this following AppleScript code into that new action.

property nameExtensions : {"mp3", "wav", "aiff", "m4a"}
on run {input, parameters}
    set thisFolder to input as string
    set newPlaylist to {}

    tell application "System Events"
        set theseFiles to every file of folder thisFolder
        set folderName to name of folder thisFolder
    end tell

    repeat with i from 1 to the count of theseFiles
        set thisFile to item i of theseFiles
        tell application "System Events"
            if name extension of thisFile is in nameExtensions then
                set thisFile to thisFile as alias
                set end of newPlaylist to thisFile
            end if
        end tell
    end repeat

    tell application "iTunes"
        set newPlaylist1 to make new playlist with properties {name:folderName}
        add newPlaylist to newPlaylist1
        play newPlaylist1
    end tell
end run

enter image description here

You can save your Automator file now and name it something like “Play in iTunes”

Now all you need to do is right-click on any folder containing your audio files that you want to be played in iTunes, and select the menu item item “Quick Action” / “Play in iTunes”

enter image description here

This will create a new playlist in iTunes with the name of the folder containing your audio files and will start playing that playlist immediately.

If you don't want that playlist to be permanent and you want to remove the files after listening to them… sounds like a good little project to get your feet wet with by adding an additional code that will do that for you.

As a side note, you may need to add more audio file formats to the first line in the AppleScript code.

Anyway I think this is all a good starting point for you

1
  • 1
    The reason for the “S” and “Z” debacle is, I have 6 Macs, 2 of which I use for coding. Those 2 have different usernames. Before I became aware of the disadvantages of hard coding my scripts, all code related files I created, just used normal spelling without the “z” (on laptop 1). Running some of these files on laptop 2 resulted in errors because they were hardcoded. So all code related files I create on laptop 2 I don't hardcode. I use the "z". Now I know that running "z" files should work on both computers and they were created on laptop 2, and “s” files should eventually be recoded
    – wch1zpink
    Commented Jan 29, 2019 at 3:32

You must log in to answer this question.

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