Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Title formatting: replacing illegal filename characters (Read 5834 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Title formatting: replacing illegal filename characters

Hi,

I am using foobar 1.0 and am trying to do something like $replace(%_path%,%_filename_ext%,)$ansi(%artist%).jpg
But nothing is done.
I mean artist is "*shells" and i still get "*shells" instead of "xshels".

Same issue with $ascii

I really need that feature if someone can help

Title formatting: replacing illegal filename characters

Reply #1
[font= "Courier New"]$ansi()[/font] converts the string from the internal UTF-8 representation to the "system code page".
[font= "Courier New"]$ascii()[/font] converts the string from the internal UTF-8 representation to ISO-8859-1, i.e. plain ASCII.
Because both those character sets contain the star character '[font= "Courier New"]*[/font]', why should the functions change it?
Filesystem-derived replacing of illegal characters is not a part of title formatting.
Full-quoting makes you scroll past the same junk over and over.

Title formatting: replacing illegal filename characters

Reply #2
you could take the easy way out like i do. i use $crc32(%artist%) to generate my filenames. ok, so i can't browse the files in explorer easily but foobar can read them and that's all i need.

Title formatting: replacing illegal filename characters

Reply #3
$ansi() converts the string from the internal UTF-8 representation to the "system code page".
$ascii() converts the string from the internal UTF-8 representation to ISO-8859-1, i.e. plain ASCII.
Because both those character sets contain the star character '*', why should the functions change it?
Filesystem-derived replacing of illegal characters is not a part of title formatting.

Ok now i see
Look at the bottom of that page
http://wiki.hydrogenaudio.org/index.php?ti...File_operations

I understood that it was what the function did :s In fact it was just the renaming tool which did that.
So it would be great to have a function that does those replacements.

I know i can write the $replace() corresponding but if changes are made i would have to update. Would be great to have such a function

Title formatting: replacing illegal filename characters

Reply #4
What do you need that for?

The album art loader and file operations already perform those replacements on their own.

Title formatting: replacing illegal filename characters

Reply #5
What do you need that for?

The album art loader and file operations already perform those replacements on their own.

i need it inside other plugins like wsh panel or panel stack splitter.
in wsh panel i can call the titleformating of foobar on a string.
And then i use that string to save files or create files.

Saying it i already know the answer. It s not a feature that foobar needs but that a plugin needs so ...
Yet i would be so great :s

Title formatting: replacing illegal filename characters

Reply #6
just write your own replace function then. it's not like windows file naming conventions are going to change any time soon, is it?

and like i said above, you can use $crc32. that would perfectly suit your needs if you weren't so fussy. do you really need to browse your cache of files?

Title formatting: replacing illegal filename characters

Reply #7
just write your own replace function then. it's not like windows file naming conventions are going to change any time soon, is it?

and like i said above, you can use $crc32. that would perfectly suit your needs if you weren't so fussy. do you really need to browse your cache of files?

crc32 wouldnt work. What i do is very complicated and i need it to work perfectly.
I already have my own jscript function to do that. The problem is that i want to allow the user to use a foobar titleformat string as a property that will be used to save an image. I want him to be able to use functions like $replace and other stuffs like that. If i wanted to permit that in jscript i would have to rewrite my own fully titleformat ....

 

Title formatting: replacing illegal filename characters

Reply #8
just write your own replace function then. it's not like windows file naming conventions are going to change any time soon, is it?


Title formatting: replacing illegal filename characters

Reply #9
It s not a feature that foobar needs but that a plugin needs so ...

For title formatting calls that produce file paths, components are expected to pass a text filter that is part of the SDK. It properly ensures that (back)slashes are replaced when a metadata %field% is evaluated, to avoid specifying unwanted subfolders. That is why you cannot just run a replacement function over the final result. Edit: It is the same with the * character. As part of the original pattern, it denotes a placeholder, but when found in a tag, it needs to be replaced.

That is the problem with introducing another programming layer above the SDK: You keep running into issues that have already been solved, and artificially limit yourself to imperfect solutions. But I guess some things will never change.

Title formatting: replacing illegal filename characters

Reply #10
It s not a feature that foobar needs but that a plugin needs so ...

For title formatting calls that produce file paths, components are expected to pass a text filter that is part of the SDK. It properly ensures that (back)slashes are replaced when a metadata %field% is evaluated, to avoid specifying unwanted subfolders. That is why you cannot just run a replacement function over the final result.

That is the problem with introducing another programming layer above the SDK: You keep running into issues that have already been solved, and artificially limit yourself to imperfect solutions. But I guess some things will never change.

So you are saying that if the component pass a text filter that will replace all illegal characters, it should work fine?
THat would be so great.

Title formatting: replacing illegal filename characters

Reply #11
Look at the bottom of that page
http://wiki.hydrogenaudio.org/index.php?ti...File_operations


BTW, on this page is written "? < > get replaced by an _. " but when i replace ? with _ cover doesn't show. I need to delete ? to get it working. Intentional?
Edit: It happens when ? is on end of album name, ex. "Is This Real?".
Edit2: Nope, redundant file, it happens everywhere.