Friday, December 15, 2017
  • Index
  •  » Automator
  •  » Transferring folder titles from parent to child -

#1 2005-05-31 06:15:54 pm

enrico sanchez
Member
Registered: 2005-05-31
Posts: 4

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:

<The Beatles>
        <A Hard Days Night>
        <Abbey Road>
        <Let it Be>
to
<The Beatles>
        <The Beatles - A Hard Days Night>
        <The Beatles - Abbey Road>
        <The Beatles - Let it Be>

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.

Enrico

Offline

 

#2 2005-05-31 06:19:55 pm

enrico sanchez
Member
Registered: 2005-05-31
Posts: 4

Re: Transferring folder titles from parent to child -

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

Offline

 

#3 2005-05-31 07:13:37 pm

BLUEFROG
Member
Registered: 2003-02-17
Posts: 273

Re: Transferring folder titles from parent to child -

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.

Applescript:


on open theFolder
tell application "Finder"
activate
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.

Cheers,
Jim Neumann
BLUEFROG


Filed under: Finder

Offline

 

#4 2005-05-31 07:26:20 pm

BLUEFROG
Member
Registered: 2003-02-17
Posts: 273

Re: Transferring folder titles from parent to child -

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
BLUEFROG

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

Offline

 

#5 2005-05-31 07:56:22 pm

enrico sanchez
Member
Registered: 2005-05-31
Posts: 4

Re: Transferring folder titles from parent to child -

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).

Thanks,

E

Offline

 

#6 2005-05-31 08:10:21 pm

BLUEFROG
Member
Registered: 2003-02-17
Posts: 273

Re: Transferring folder titles from parent to child -

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!:P 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
BLUEFROG

Offline

 

#7 2005-06-01 11:32:30 am

hhas
Member
Registered: 2004-04-29
Posts: 461

Re: Transferring folder titles from parent to child -

BLUEFROG wrote:

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.


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.

HTH


Learn AppleScript, 3rd edition - Sanderson & Rosenthal (Apress)

Offline

 
  • Index
  •  » Automator
  •  » Transferring folder titles from parent to child -

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)