HydrogenAudio

Hosted Forums => foobar2000 => Support - (fb2k) => Topic started by: comox on 2009-05-13 07:28:32

Title: Is it possible to automatically rename a folder?
Post by: comox on 2009-05-13 07:28:32
Hello,

what I wish for is a function to rename a folder (that contains an Album, Compilation, EP...) by its tag (group column). E.g. if I I have an album in my playlist that's correctly displayed as "Michael Jackson - Thriller" in the group column, but the folder is named as "surgery accident", it shall be possible to rename it by the group column.

Is there any possibility?

Greetings.
Title: Is it possible to automatically rename a folder?
Post by: FuzzyLogic on 2009-05-13 08:36:58
As far as I know the only way to do that within foobar would be using:
right klick -> file operations -> move to...
There you can setup the destination folder the way you want using %artist% - %album% (and you can rename the files to in the same go if you need to).
Check "move entire source folder content" if your sure everything in the folder belongs there  and "remove empty source folder".

Once you have that setup right I would advise to save the setup as a preset. That way next time you need it will be included in the context menu.
(right klick -> file operations -> move to... -> preset)

But a simple "rename folder to..." would actually be nice.
"nudge nudge wink wink devs say no more say no more"
 

Title: Is it possible to automatically rename a folder?
Post by: d'Wooluf on 2009-05-13 09:30:29
The problem is that there is no concept of relative addresses within Foobar file operations (my understanding anyway). So yes, you can rename the parent folder but you have to supply the path to that folder. If there were a token that you could use in the rename string for <current directory> or <parent directory>, you could make a preset for changing the name of the parent folder that would work anywhere within your file structure. There's probably a reason why such a thing was not included. It would be interesting to know the reason.
Title: Is it possible to automatically rename a folder?
Post by: Yirkha on 2009-05-13 12:08:21
If there were a token that you could use in the rename string for <current directory>...
%path% = "C:\Music\Artist\Album\Track.mp3", $directory_path(%path%) = "C:\Music\Artist\Album\"
...or <parent directory>, ...
%path% = "C:\Music\Artist\Album\Track.mp3", $substr(%path%,0,$strrchr($substr(%path%,0,$sub($strrchr(%path%,\),1)),\)) = "C:\Music\Artist\"
Title: Is it possible to automatically rename a folder?
Post by: Nemphael on 2009-05-13 12:17:30
...or <parent directory>, ...
%path% = "C:\Music\Artist\Album\Track.mp3", $substr(%path%,0,$strrchr($substr(%path%,0,$sub($strrchr(%path%,\),1)),\)) = "C:\Music\Artist\"

$replace(%path%,$directory(%path%,1)\%filename_ext%,)
Title: Is it possible to automatically rename a folder?
Post by: FuzzyLogic on 2009-05-13 12:20:45
I have been fiddeling around a bit with %path% in the "file operations...".
For some reasone it doesn't result in for example "C:\Music\Artist\". I end up with something like "C-\Music\Artist\" which makes it rather useless.
Anyone else getting this result?
Title: Is it possible to automatically rename a folder?
Post by: Nemphael on 2009-05-13 12:25:54
You have to enter two queries: Destination Folder is the folder you want to put your music in (Say, C:\Music), then you can use a File Name Pattern: %artist% - %album%.
Title: Is it possible to automatically rename a folder?
Post by: FuzzyLogic on 2009-05-13 12:40:47
I am aware of that
What I was trying to get was a way to make a preset "that would work anywhere within your file structure." as d'Wooluf said it so fitting.
But it seems that title formatting cant be used in the first query for the destination folder.
I tried to use $cut(%path%,3) which should leave just the "C:\" from what I understand.
But I get an "invalid/nonexistent target folder" in the preview.

EDIT: btw... sorry to the OP for somewhat hijacking the thread
Title: Is it possible to automatically rename a folder?
Post by: Yirkha on 2009-05-13 13:07:06
Only like this:

Destination folder: C:\
File Name Pattern: $substr(--whatever-custom-formatting-from-%path%--,3,999)
Title: Is it possible to automatically rename a folder?
Post by: itisljar on 2009-05-21 15:26:33
I don't get this. If I do what you proposed
$substr(--%album artist% - %album%[ '['%date%']']/%tracknumber% - %title%--%path%,3,999)

I get complete nonsense.

When using just
$substr(%path%,3,999)

I get the current path. But I want to add a date at the end of a folder in [1987] format. How do I do that?

now I have

Yazoo - Only Yazoo (The Best Of)
I want
Yazoo - Only Yazoo (The Best Of) [1999]

...and to work in current folder. Where to put [ '['%date%']']?

How?
Title: Is it possible to automatically rename a folder?
Post by: Yirkha on 2009-05-21 15:47:15
I meant the whole [font= "Courier New"]--whatever-custom-formatting-from-%path%--[/font] as to be replaced.

Anyway, exactly for what you want to do:
[font= "Courier New"]$substr(%path%,3,$sub($strrchr(%path%,\),1))' ['%date%']'\%filename%[/font]

[font= "Courier New"]$substr(%path%,3,$sub($strrchr(%path%,\),1))[/font] -- Get the part from from the 4th char (skip the C:\ prefix) to the last \ (at the end of the last directory name).
[font= "Courier New"]' ['%date%']'\%filename%[/font] -- Append the date in brackets, then use the original filenames in the folder.
Title: Is it possible to automatically rename a folder?
Post by: itisljar on 2009-05-22 00:11:02
Yirkha, thank you, it works as intended.
I just don't understand this scripting, thank you for helping.
Title: Is it possible to automatically rename a folder?
Post by: mll on 2013-01-31 09:19:12
Only like this:

Destination folder: C:\


Hi, I'm resurrecting this very old - and interesting - thread to ask if, as of today, your workaround is still necessary, or if "Destination folder" can be scripted to guess the drive where the files are.

In my case, music can be on C: or on N:, and I'd like to move my files
from
Code: [Select]
[Drive]:\[original path]\[original filename].mp3

to
Code: [Select]
[Same drive]:\$directory_path(%path%)\%album%\$num(%discnumber%,2).%tracknumber%-%totaltracks% %artist% - %title%