INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Create Letter Folders Using the Rename Move Copy Tool?  (Read 8516 times)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Create Letter Folders Using the Rename Move Copy Tool?
« on: November 14, 2010, 05:58:02 pm »

So... I have a fairly large library.  Not the biggest, but large enough certainly.  My M:\Music\ folder is organized using this Folder system currently:

[Artist]\[Album]\if(isempty([Disc #],1),,[Disc #]

Which simply creates [Artist]\[Album] folders, and then includes [Disc #] subfolders if a disc number exists.  Unfortunately, I have so many artists in my library that this has slowly become somewhat ungainly when you try to browse it using Windows Explorer or via my SFTP site.  I'd like to now change it to have a new top-level folder structure based on the first letter of the artist's name, like so:

M:\Music\B\Beastie Boys\The In Sound From Way Out\12 - Transitions.mp3

However, I see two problems with trying to accomplish this...

1. Most of my artists that start with an article are formatted like "Beatles, the".  However, some are not.  MC auto-organizes these properly anyway, ignoring the articles when sorting, so it doesn't bother me.  For the rename operation, though, I want these to show up "properly" under the right letter.  If I use a simple Left() expression, then won't it return "T" for things that start with "The"?

2. I'd also prefer to have a "catch all" folder for my artists that have non-alphabetic names, like 2pac and 2 Live Crew.  I basically want to replicate the functionality of an Artist Pane with Grouping set to 1, which would show a 0-9 for those non-alphabetical files.

Has anyone sorted out a way to do this?  Is there some special grouping-like expression I can use to accomplish my goal, or should I give up on it?
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #1 on: November 15, 2010, 01:30:27 am »

First of all, there's a closing parenthesis missing from your expression above, at the end, right after [Disc #]. The expression may still work without it, but you will definitely run into problems if you try to build on that expression any further.

As for your question, here's one I made earlier that might fit the bill for you as it is without any editing. I use it as the first category in my main audio view scheme, and you can see it in action here:


If that looks like it will do the job for you, my advice would be to save the expression as a new calculated library field, I called mine Artists, and the use that in your renaming template.
You don't mention "Multiple Artist" albums. This expression keys off the [album artist (auto)] field and lumps all the "Multiple" fellows under "(Various)"

My proposal for your new library field goes like so:
if(isequal([album artist (auto)],multiple,8),/(Various/),if(isequal(mid([album artist (auto)],0,4),the/ ,1),mid([album artist (auto)],4,1),if(isequal(Mid([album artist (auto)],0,1),1,6),0 - 9,Mid([album artist (auto)],0,1)))

What it does:
  • Checks for Multiple Artists, and places any found under (Various Artists)
  • Checks for [album artist (auto)] values that start with "the " (note the trailing space) and if found, returns the first letter of the next word.
  • Checks to see if the first character of [album artist (auto)] is greater than or equal to 1, and if so, return 0 - 9.
  • Finally, if all the previous checks have returned as false, return the first character of the [album artist (auto)] value.


So, assuming that works for you, and your new library field is called Artists, your new folder template would be:
[artists]\[Artist]\[Album]\if(isempty([Disc #],1),,[Disc #])

Any good?

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #2 on: November 15, 2010, 09:30:52 am »

First of all, there's a closing parenthesis missing from your expression above, at the end, right after [Disc #]. The expression may still work without it, but you will definitely run into problems if you try to build on that expression any further.

That was a copy/paste failure into the forum, but thanks.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #3 on: November 15, 2010, 09:41:49 am »

What it does:
  • Checks for Multiple Artists, and places any found under (Various Artists)
  • Checks for [album artist (auto)] values that start with "the " (note the trailing space) and if found, returns the first letter of the next word.
  • Checks to see if the first character of [album artist (auto)] is greater than or equal to 1, and if so, return 0 - 9.
  • Finally, if all the previous checks have returned as false, return the first character of the [album artist (auto)] value.


So, assuming that works for you, and your new library field is called Artists, your new folder template would be:
[artists]\[Artist]\[Album]\if(isempty([Disc #],1),,[Disc #])

Any good?

Well... That is pretty darn good.  I don't use the Multiple Artist/Album Artist features at all.  I prefer my "multiple artists" albums to show up separately under their respective Artist's "categories" under all circumstances.  There is nothing that bothers me more than seeing a (Various) or (Multiple) option under "Artist", for some reason.  If I want to listen to just that Soundtrack Album (or whatever) I'll just go find the album itself, but that's just me.  So I'd have to modify that expression to use [Artist] instead of [Album Artist (auto)].  No biggie.

The article checking system you came up with is clever.  However, I'd still have to worry about other articles ("a" and "an", mostly).  These are, of course, less common, but still could be an issue.  I don't know if it is worth bothering to modify the expression for these, though...
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #4 on: November 15, 2010, 01:01:01 pm »

It's worth bothering about because if the expression allows even just one single file to slip through, it's unreliable, and it will annoy you! Once you save this new field, it should fall slap bang into the "set-it-and-forget-it" category.

So, keyed off the [artist] field, taking "the " "an " and "a " into account, the tweaked expression looks like so:

if(isequal(mid([artist],0,4),the/ ,1),mid([artist],4,1),if(isequal(mid([artist],0,3),an/ ,1),mid([artist],3,1),if(isequal(mid([artist],0,2),a/ ,1),mid([artist],2,1),if(isequal(Mid([artist],0,1),1,6),0 - 9,Mid([artist],0,1))))

Any better?

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #5 on: November 15, 2010, 01:08:57 pm »

You're amazing.

Will try it out tonight.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #6 on: November 15, 2010, 08:12:43 pm »

Thank you very much, kind sir.  You are an Expression Grand Master.

Interestingly, apparently I have no artist who's name begins with "X".
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #7 on: November 16, 2010, 01:21:06 am »

You're more than welcome. Glad it works for you. Not sure about that "Grand Master" tag, but thank you anyway.

I have one artist beginning with "X"...
* marko is listeng to: 'Lazy' by 'X-Press 2 Feat. David Byrne' from the album 'The New Classic Chillout Album' [Duration: 3:53 | 192 kbps mp3 (5.3 MB) | rated 2/5 | played 3 times ~ last played 4.99 years ago  (20/11/05)

It's not very good!!

mark_h

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1854
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #8 on: November 16, 2010, 04:40:15 am »

Just want to add that I do something similar, but as usual, Marko's expressions trump mine, so I'll be using his from now on.  Thanks! :D

Cheers,

Mark
Logged

Jaguu

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1336
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #9 on: November 16, 2010, 05:25:40 am »

I always had an alphabetical listing of the artist. It is displaying like that:

Others
A
B
C
...
Z

I was wondering how I set it long ago and found out: Customize View > View as Panes > Select "Artist" > Edit > Settings > Grouping Size = 1.

If I set Grouping size to 3 I get the following list:

ABC
DEF
GHI
...

Definitely not as sophistaced as markos expressions, but simple enough for my needs.



 
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #10 on: November 16, 2010, 07:40:18 am »

Jaguu, yes, I knew I could do that for a view. I wanted to know how to apply that type of system to my folders on disk.  That's what marko helped with...
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Peter_T

  • Galactic Citizen
  • ****
  • Posts: 352
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #11 on: March 28, 2020, 11:27:12 am »

Hello!  I know this is a very old post, but this is exactly what I was hoping to do...  except it gives me a folder named "Expression Error (unknown)"... has the expression language or syntax changed since 2010?

Thanks!!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #12 on: March 28, 2020, 11:40:05 am »

Very old indeed!

A lot changed, but not such that should affect this... except... MC used to be more forgiving of trailing errors, which is exactly what we have here.
I'll blame copy/paste, but there's a missing closing parenthesis at the end. This should work...
Code: [Select]
if(isequal(mid([artist],0,4),the/ ,1),mid([artist],4,1),if(isequal(mid([artist],0,3),an/ ,1),mid([artist],3,1),if(isequal(mid([artist],0,2),a/ ,1),mid([artist],2,1),if(isequal(Mid([artist],0,1),1,6),0 - 9,Mid([artist],0,1)))))
The expression function library has evolved greatly since this, with the addition of things like Regex and ifelse(), meaning a more elegant solution may be achievable, but as-is, this still works.

-marko.

Peter_T

  • Galactic Citizen
  • ****
  • Posts: 352
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #13 on: March 28, 2020, 12:39:55 pm »

Amazing - thanks!!
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #14 on: March 28, 2020, 03:24:58 pm »

You're welcome, and, massive props to yourself for utilisation of the much overlooked search feature ;)

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #15 on: March 29, 2020, 02:29:38 am »

Found this from MrC, using the black art of Regex, that does exactly the same as that nested string of "If()s"....

Code: [Select]
Regex([Artist], /#^(?:(?:the|an|a) +)?(.)#/,-1)if(Compare(1[R1], >=, 10), 0 - 9, [R1])

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #16 on: March 29, 2020, 07:09:10 am »

Think we should add a function to do this?
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #17 on: March 29, 2020, 10:27:44 am »

Tough one, not least because I'm struggling to visualise how it might be constructed, and, as these just work, and can be saved as a custom library field for ease of use elsewhere, not seeing the benefit either.

So, in my "Whereisit?" view, I have a pane that contains these letters based on the expression above. The next pane, takes the same expression (not the regex coz I don't know how), but returns the first two characters, which allows me to quickly arrive at the sought for artist rather than scroll through a pane of many thousands of entries.

A function then, would need:
  • a name
  • source data
  • delimited list of articles to ignore
  • number of characters to return (defaults to 1)
  • default mode 0 to group numerical and special character results under 0 - 9
  • optional mode 1 to not group numerical results
Letter([Artist],The;An;A) would do what the expressions above do.
Letter([Artist],The;An;A,2) would do what the expressions above do, but return two characters instead of one.
Letter([Artist],The;An;A,2,1) would return two characters and not group numerical results.

Is that possible?
Would it be useful to others?

-marko

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #18 on: March 29, 2020, 10:49:34 am »

We already have a list of articles (even editable by the user).  So would it be enough to just have a Mode flag to ignore the articles?  Or just always ignore the articles?

So to be clear,
Letter(The Who, 2) would return Wh
Letter(1979, 2) would return 0-9,0-9
Letter(1979, 2, 1) would return 19

Thanks for brainstorming with me!
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #19 on: March 29, 2020, 10:57:49 am »

Looks good to me (assuming the double "0 - 9,0 - 9" is a typo).

Personally, I would default to ignoring articles with a mode switch to not ignore them?

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #20 on: March 29, 2020, 11:00:03 am »

Looks good to me (assuming the double "0 - 9,0 - 9" is a typo).

We asked for two characters so shouldn't two numbers be a list of the number value?
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #21 on: March 29, 2020, 11:03:02 am »

For articles, how about:
Letter(The Who, 2, 3) would return Th

The last field is "Flags".  1 would be no number grouping.  2 would be don't ignore articles.  The flags are or'd together.
Logged
Matt Ashland, JRiver Media Center

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #22 on: March 29, 2020, 11:24:02 am »

How about using # for numbers?
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #23 on: March 29, 2020, 01:18:41 pm »

For articles, how about:
Letter(The Who, 2, 3) would return Th

The last field is "Flags".  1 would be no number grouping.  2 would be don't ignore articles.  The flags are or'd together.
How about using # for numbers?

Both of these make sense to me, reduces complexity and numbers would still be first item listed.

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #24 on: March 30, 2020, 08:06:02 am »

Next build we'll have this:
NEW: Added the expression function Letter(...) to output the starting letters of a string.

Thanks a lot for all the help :)
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #25 on: March 30, 2020, 11:11:19 am »

Working as expected. A lot quicker to arrive at too. Thanks.

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42383
  • Shoes gone again!
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #26 on: March 31, 2020, 07:55:42 am »

The build is now public:
https://yabb.jriver.com/interact/index.php/topic,124712.0.html

Note that asking for output when there's nothing to output, like Letter(the ,2) just outputs empty.  That seemed as good to me as outputting a special character, but speak up if you think differently.

Thanks.
Logged
Matt Ashland, JRiver Media Center

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #27 on: March 31, 2020, 11:27:50 am »

How would the rename tool deal with empty output? I can't test right now...

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Create Letter Folders Using the Rename Move Copy Tool?
« Reply #28 on: April 13, 2020, 07:02:45 am »

I didn't even notice this got done. Awesome, Matt. I can remove my custom Library Field (if I ever get around to removing it everywhere it is used, that is).
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up