INTERACT FORUM

Please login or register.

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

Author Topic: How to parse a directory structure top down  (Read 678 times)

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
How to parse a directory structure top down
« on: April 28, 2018, 07:42:56 am »

Hi all,
A friend of mine has 120'000 untagged files in a given folder structure. I would like to help him extract the Artist and Album information contained in the folder names and put them into tags. The folder stucture is straightforward, but still a bit challenging:

W:\
  \Do not parse this directory\
    \Artist\
      \Do not parse this directory\
        \Album\
          \Sometimes there is a folder here indicating Disc 1,2,3\
            \filename.ext\

One of the difficulties is the Discx folder which sometimes exists and sometimes not. This means I need to parse the folder structure from the top (Root of W:\) and not from the bottom (filename.exe), as I would usually do. Also I need to ignore the content of two folder levels.
I plan to do this with F12 Fill Properties from Filename. I am familiar how to parse from the filename up, but not what expression to use to parse top down and to ignore a given folder level.
I would appreciate any suggestions.
Thanks a lot
Rudi
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How to parse a directory structure top down
« Reply #1 on: April 28, 2018, 01:25:37 pm »

Inserting [] in the Fill Properties from Filemame template will “skip” that part of the string being parsed. Think of it just like filling a Field, but filling a special “null” field that goes nowhere.

It always parses from the file name up, not the reverse, but it is easy to skip sections as needed.
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: How to parse a directory structure top down
« Reply #2 on: April 28, 2018, 01:27:05 pm »

For the disc folders, are they prefixed with “disc” or any other text you can search for so that you can search for them and do them in a separate batch?

If not, there’s another way but it’ll take some more explaining...
Logged
"Some cultures are defined by their relationship to cheese."

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

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Use Regex?
« Reply #3 on: April 29, 2018, 02:43:16 am »

Thanks a lot, Glynor
I had an idea how to do this, but I would need to use Regex, which I have very little experience with.
In reality the directory structure looks as follows:

For 80% of the library, it is quite standard:
W:\
  \ROCK A-F\
    \Artist\
      \Album\
This does not cause any issues.

For about 20% of the library (the 120'000 tracks in question) it is.
W:\
  \ROCK A-F\
    \Artist\
      \z_Outtakes & Live\
        \Album\
          \Sometimes there is a folder here indicating Disc 1,2,3\
            \filename.ext\
He uses this structure to find the outtakes (he browses by folders, as he has not tagged anything yet, which is the challenge).

The folder "z_Outtakes & Live" is always spelled exactly like this, so I could use it as an anchor. Artist sits above it and Album below it.

If I used Regex on filename(path) and parsed for "z_Outtakes & Live" and then extracted the text between the backslashes to the left and put it into the Artist Tag, I should be home. Same to the right for Album.

Then I would put the Regex into an expression column to check whether the output is correct. Finally put the Regex into the Artist and Album fields to fill them.

I have searched for a Regex example to do this, but have not found anything. How would I do this in Regex?

Logged

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Re: How to parse a directory structure top down
« Reply #4 on: May 01, 2018, 10:36:18 am »

As this has turned into more of a Regex question, I will start a new thread with an adapted title.
Logged
Pages: [1]   Go Up