I'm not sure where the place is that the developer reads suggestions and stuff, so I'll post this here. I use $directory(%_path%,1) to get the album folder, but there is a directory that is 1 or somtimes 2 directories back from that which I want to get but can't using that code.
My directory layout:
F:\Albums\New\Date\AlbumFolder\file.mp3
F:\Albums\New\Date\AlbumFolder\file.mp3
F:\Albums\New\Date\Genre\AlbumFolder\file.mp3
F:\Albums\New\Date\Genre\AlbumFolder\file.mp3
F:\Albums\SomeSortedFolder\AlbumFolder\file.mp3
F:\Albums\SomeSortedFolder\AlbumFolder\file.mp3
Right now I can easily grab anything from the back of the path (for example the AlbumFolder) easily, but I'd like to be able to grab as many folders from the FRONT that I want (the New/SomeSortedFolder). I hope this makes sense. To have this feature would make me reaaaaally happy
For the past year or so I guess I've been using this to get the job done, but it doesnt work that great:
$trim($substr(%_path%,$add($strchr(%_path%,.),2),$sub($strrchr($substr(%_path%,0,45),\),1)))
I'm open for any other suggestions on how to get this done too.
Ever seen "titleformat_help.html" in foobar's directory, or the online Title Formatting documentation (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Titleformat_Reference#.24directory.28x.2Cn.29) ?
$directory(X,N)
Extracts directory name from file path X, goes up by N directory levels.
example path .... "X:\Music\Genre\Artist\Album\file.mp3"
$directory(%path%,
1)
returns: "Album"
...(%directory% also returns: "Album")$directory(%path%,
2)
returns: "Artist"
$directory(%path%,
3)
returns: "Genre"
etc.
Yeah, the number decided how many steps back to go from the end of the file path. I would like to have the option to do the exact same thing, but go from the start of the file path.
My example:
X:/Music/Genre/Artist/Album/file.mp3
$directory(%_path%,1) returns "Album"
$dirfromstart(%_path%,1) returns "Music"
Using that example, $dirfromstart(%_path%,1) would always return "Music" regardless of how many subfolders I create inside it.
yatahaze,
I agree totally - I have also used TAGZ to try and extract directories from the start of the path.
I always thought that $directory() was the wrong way round - it should use negatives to move up the tree and positives to move down.
example path .... "X:\Music\Genre\Artist\Album\file.mp3"
$directory(%path%,-1) returns: "Album"
$directory(%path%,-2) returns: "Artist"
$directory(%path%,-3) returns: "Genre"
etc
and
$directory(%path%,1) returns: "Music" ...(%directory% also returns: "Album")
$directory(%path%,2) returns: "Genre"
$directory(%path%,3) returns: "Artist"
etc
Maybe $directory() could do the reverse of this (so as not to wreck existing scripts) use the negative numbers to indicate that you want to come from the start?
Cheers,
c0utta
I'm sorry... I completely missed the point - that you wanted to go N levels starting at the beginning of the path.
Yes, that summed it up. Now, is this somewhere where anyone is actually gonna see it and do something with it? heh
You can use this:
$puts(dir,%path%)
$puts(directory1,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory2,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory3,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory4,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory5,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
with "F:\Albums\SomeSortedFolder\AlbumFolder\file.mp3"
$get(directory1) returns Albums
$get(directory2) returns SomeSortedFolder
$get(directory3) returns AlbumFolder
$get(directory4) returns file.mp3
$get(directory5) returns file.mp3, too. This is the only problem...
You can use this:
$puts(dir,%path%)
$puts(directory1,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory2,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory3,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory4,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
$puts(directory5,$left($put(dir,$substr($get(dir),$add($strstr($get(dir),\),1),999)),$sub($strstr($get(dir),\),1)))
with "F:\Albums\SomeSortedFolder\AlbumFolder\file.mp3"
$get(directory1) returns Albums
$get(directory2) returns SomeSortedFolder
$get(directory3) returns AlbumFolder
$get(directory4) returns file.mp3
$get(directory5) returns file.mp3, too. This is the only problem...
[a href="index.php?act=findpost&pid=378526"][{POST_SNAPBACK}][/a]
But this is too complex to use. Is there a funtion do the same thing?
How do I use this? I added that code to the columns ui globals section, then I made a column and put $get(directory3) in it, but nothing shows. Am I doing that right?
Edit: Nevermind, I chucked all the code with $get(directory3) at the end into a column and it works PERFECTLY! Exactly what I needed.. thanks!!
Much shorter solution:
$directory(%path%,$sub($sub($len(%path%),$len($replace(%path%,\,))),1))
The number at the end defines how many directory levels it should go down from the root.