Transferring folder titles from parent to child -

I am attempting to construct a script, which helps me organize my iTunes music lib.

I have found iTunes’ “keep music folder organized” function to be both messy, and unreliable.
And being the neurotic file organizer that I am, I have decided to organize the files (semi)manually.

trouble is, I have over 3000 albums in my collection.

Could somebody suggest a way to transfer the title of a folder, to it’s enclosed folders as a prefix ? eg:


And then move the renamed folders to a different location?

I would appreciate any help I can get on this one, it has been driving me crazy.

Thanks in advance.


btw, I would like this script to work on all the folders [and their enclosed folders] in my itunes lib.

enrico: Try this out. Save it as an Application and it will be a droplet. This is NOT recursive so it will only go one level deep. You can drop multiple folders on it.

on open theFolder
tell application "Finder"
repeat with parentFolder in theFolder
set theFolder to parentFolder
set parentName to name of theFolder
set childFolders to (every folder of folder theFolder)
repeat with thisFolder in childFolders
set name of thisFolder to (parentName & " - " & (name of thisFolder) as string)
end repeat
end repeat
end tell
end open

It’s a quickie but it should do what you’ve described. Not, there’s no error checking for folder name lenghts or anything like that. But it should be a decent core to get you started.

Jim Neumann

BTW, I just noticed something in my script. Yes, it work and works just fine but notice…

on open theFolder – This contains a list of the folders dropped.

repeat with parentFolder in theFolder – This gets each item in theFolder
set theFolder to parentFolder – Then I used the same variable name here. Not very smart but it works.

Be very careful with reusing variables like this. (This was hacked together on my laptop and retyped on my PC while trying to read my code on the laptop.) For clarity’s sake, I would set the second theFolder to another variable name.

Sorry for any confusion.
Jim Neumann

PS: Did you mean to post this in the Automator section? Or maybe you wanted an Automator solution?? Anyways, have fun.

Hey wow!

Now that was cool, It did it straight away no wait!!!

Thanks very much, I was half heartedly hoping it could be done in automator (im learning) however, this script seems to have done exactly what I wanted (short of moving the folders).



Glad it worked out. I wasn’t sure where or what you wanted to move (or if you wanted copies instead of moving,etc.,etc.)

I’m not running Tiger so I don’t have Automator. From what I see it’s not nerdy enough for me!:stuck_out_tongue: I would encourage you to dig into pure Applescript (and XCode 2.0 once you get your feet wet.) You can do some incredible things with it. I run about 15 Macs at work and a PC at home. While I would never live without my PC, if anyone asks what the very best thing about a Mac versus a PC is, the answer is simple… Applescript. As deficient as a PC may seem to many people, the only thing that bothers me at all is the lack of a fluid, native scripting language.

Dig deep and have fun,
Jim Neumann

There are plenty of fine scripting languages freely available for Windows, often with native bindings to stuff like COM and WSH. Many are available on Mac, Unix and/or Linux as well. e.g. Try Perl, Python, Rexx, Ruby or Tcl for starters.