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 6502
 
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 Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW
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 6502
 
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 Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW
Red Menace is offline   0 Reply With Quote
Old Jul 8, 2013, 09:43 AM   #5
garysdavies
macrumors newbie
 
Join Date: Jul 2013
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 by garysdavies; Jul 8, 2013 at 09:54 AM.
garysdavies is offline   0 Reply With Quote
Old Jul 10, 2013, 06:21 PM   #6
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: 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.
__________________
Space Corps Directive 34124
kryten2 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

Similar Threads
thread Thread Starter Forum Replies Last Post
Automator, save to source folder? wallraff OS X Mavericks (10.9) 0 Mar 11, 2014 04:10 AM
Automator folder action not working NYR99 OS X 0 Mar 11, 2014 01:48 AM
Automator - Move Video Files From One Folder To Another Levi Alberta Mac Programming 2 Jan 30, 2014 10:35 AM
Automator Workflows/Application/Service/Folder Action SweeneyD24 OS X 0 Mar 1, 2013 01:15 AM
Automator / Applescript > copy to folder mynameismatt89 Mac Programming 2 Feb 6, 2013 04:32 PM

Forum Jump

All times are GMT -5. The time now is 06:57 AM.

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

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC