Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 25, 2013, 10:42 AM   #1
whitecastle
macrumors newbie
 
Join Date: Jan 2013
Possible to get folder name in Automator?

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.

whitecastle is offline   0 Reply With Quote
Old Jan 25, 2013, 11:27 AM   #2
Red Menace
macrumors regular
 
Join Date: May 2011
Location: Littleton, 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.
__________________
MacBook Pro / OS X Mountain Lion (10.8.3) / Xcode 4.6 / [various (much) older stuff keeping dust off the shelves]
Red Menace is offline   0 Reply With Quote
Old Jan 25, 2013, 04:51 PM   #3
whitecastle
Thread Starter
macrumors newbie
 
Join Date: Jan 2013
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
        filter input to only basefolder (totally made up command) 
end run
And at what point in the workflow would this script go?
whitecastle is offline   0 Reply With Quote
Old Jan 25, 2013, 10:04 PM   #4
Red Menace
macrumors regular
 
Join Date: May 2011
Location: Littleton, 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
__________________
MacBook Pro / OS X Mountain Lion (10.8.3) / Xcode 4.6 / [various (much) older stuff keeping dust off the shelves]
Red Menace is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:49 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC