Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whitecastle

macrumors newbie
Original poster
Jan 25, 2013
2
0
Hi,

I'm not a programmer but I'm trying to build an Applescript that will take all the files in a folder and create a playlist in iTunes from that folder.

I can successfully get the action to complete, however, the name of the playlist is set to the path of every file within the folder. So the playlist name is super long, being the full path of every track in the folder back to back.

Is there a way to capture JUST the folder name and set it as the variable to use when naming my playlist?

Here's an image of the current workflow: Note the FolderName variable is just a placeholder.

workflow.png
 

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
You can use a third party action or a Run AppleScript action to get the name of the folder to put into a variable, for example:

Code:
on run {input, parameters}
	tell application "System Events" to return name of first item of input
end run

Note that your application will accept multiple folders and files, so you should probably filter for folders or convert to a Service that just accepts folders.
 

whitecastle

macrumors newbie
Original poster
Jan 25, 2013
2
0
Thanks for your reply.

I'll have to figure out the code, but would it read something like this:

Code:
on run {input, parameters}
	tell application "System Events" to return name of first item of input
        [COLOR="Red"][I]filter input to only basefolder (totally made up command)[/I][/COLOR] 
end run

And at what point in the workflow would this script go?
 

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
You can use a Filter Finder Items action, for example:

  1. Your application is passed files and folders
  2. Filter Finder Items - Find files where kind is folder
  3. Set Value of Variable (e.g. "input") - save original input folder(s)
  4. Run AppleScript - get name of first folder
  5. Set Value of Variable (e.g. "folder name") - save folder name
  6. Get Value of Variable "input" - set option to Ignore input
  7. Get Folder Contents
  8. Import Files into iTunes - use "folder name" for new playlist
 

garysdavies

macrumors newbie
Jul 8, 2013
1
0
MOre help

Hi Whitecastle,

I have a similar issue and don't quite follow the script. I am trying to get automator to do the following. I have a folder of pics. I would like to name an album in iPhoto the same as the folder and import the pics.
 
Last edited:

kryten2

macrumors 65816
Mar 17, 2012
1,114
99
Belgium
Just follow Red Menace's steps and replace step 8 with :

8. Import Files into iPhoto - use "folder name" for new album

I'm not quite sure if that is the correct name of the action.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.