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: Foobar2000 and long folder/file name handling (Read 8984 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Foobar2000 and long folder/file name handling

Hi all,

I have a problem with the Windows limitation in path length while renaming my files with Foobar after tagging it. Unfortunately Foobar doesn't cut filename length when it is too long so it wont get copied/moved/renamed which is terrible for an automated process.

Scenario:
- Tag a classical album like "Leonard Bernstein - The Symphony Edition" with MusicBrainz
- Sample output is something like this (with my personal settings which are: %album artist% - (%date) - %album%\%tracknumber% - %title%) > I already shortened the %album%  by hand and left out the %artist% in the file name but that wasn't enough:
Code: [Select]
Leonard Bernstein - (2010) - The Symphony Edition - CD 58 (Peter Ilyich Tchaikovsky: Symphony No.3 & 4)\06 - Symphony No.4 In F Minor, Op.36: I. Andante Sostenuto, Moderato Con Anima, Moderato Assai, Quasi Andante, Allegro Con Anima, Allegro Vivo

- some files like these will not get copied/renamed/moved due to 255 path length limitation and you will get an error.

How do you guys get around this problem without manually editing all file names (In this case 60 CDs!)?


My workaround described here by creating column that shows the overall path length:
Code: [Select]
$len(%album artist% - '('%date%')' - %album% %tracknumber% - %title%)

and than modifed only the ones that were to long. But thats really a pain.

Request: Foobar2000 should autmatically shorten file names ending with "..." (and show a warning of course)

Foobar2000 and long folder/file name handling

Reply #1
You could enter something like this in the "File name pattern" box:
Quote
$ifgreater($len(enter entire path of destination folder here\%album artist% - '('%date%')' - %album%\%tracknumber% - %title%),250,$cut(%album artist% - '('%date%')' - %album%\%tracknumber% - %title%,specify a number here that also takes the length of the path of your destination folder into account),%album artist% - '('%date%')' - %album%\%tracknumber% - %title%)

Make sure you carefully scrutinize the contents of the preview pane if you use this as it hasn't been tested..

Consult the title formatting reference for other options.

Foobar2000 and long folder/file name handling

Reply #2
my whole "move" script is
$if(%album%,$ifgreater($len(%album%),80,$abbr(%album%),%album%)$if(%band%, - $abbr(%band%))$if(%conductor%, - $abbr(%conductor%))$if(%split%, - $abbr(%split%))$if(%reissue%, %reissue%))\$if(%tracknumber%,$if(%discnumber%,CD $num(%discnumber%,2) - %tracknumber% - $abbr(%title%),%tracknumber%),%title%)

i use $abbr() alot. %album% gets shortened if it is longer than 80 characters, %band% and %conductor% gets always abbreviated, same goes for the tracktitles.

result looks following:
\Pjotr Iljitsch Tschaikowski\Symphonie Nr. 4 In F-moll - VP - HVK\CD 01 - 01 - AS-MCA-MAQAAV.flac
(Vienna Philharmonic, Herbert von Karajan, Andante Sostenuto - Moderato Con Anima - Moderato Assai, Quasi Andante- Allegro Vivo)

i really don't care alot about files/folders as long as they are able to correctly seperate two releases, tags are what matter.



Foobar2000 and long folder/file name handling

Reply #3
Thank you guys. I Think the Abbreviaton script is a bit to much for me because I'd like the file names to be humanly readable, because I use different systems all the time or bring my music to a friend...

But in my opinion the foobar software should take care of a problem like that if it occures without me having to write a script.

I'll try the scripts above but other ideas are more than welcome.

Foobar2000 and long folder/file name handling

Reply #4
But in my opinion the foobar software should take care of a problem like that if it occures without me having to write a script.


that's not likely. foobar generally only ever does what you explicitly tell it to.

using the $cut function BenB mentioned would be the way to. here is how i'd approach it:

presumably a full readable folder structure is more important than the filename? have you checked to see what the longest possible folder name could be? using the method you mentioned above for determining file length, you could do something similar, adding the base folder in as well....

Code: [Select]
$len(D:\music\%album artist% - '('%date%')' - %album%)


subtracting the highest value from 255 will give a worst case scenario on what your shortest filename could be.

if it's acceptable, you could use a script something like....

Code: [Select]
%album artist% - '('%date%')' - %album%\$cut(%tracknumber% - %title%,$sub(243,$len(%album artist% - '('%date%')' - %album%)))


i've actually used 243 in my example to take into account the base folder name length and file extension. you may need to tweak it a little for your setup.

 

Foobar2000 and long folder/file name handling

Reply #5
I don't know if it will help you, but when you've got trouble with long filenames you can use UNC:

\\?\C:\Folder\Subfolder\File.mp3

Foobar2000 and long folder/file name handling

Reply #6
I don't know if it will help you, but when you've got trouble with long filenames you can use UNC:

\\?\C:\Folder\Subfolder\File.mp3


does that hurt performance?
can foobar have the media library as UNC path?

Foobar2000 and long folder/file name handling

Reply #7
could you please explain UNC and how to use it? I didn't even understand the wikipedia article... :/

Foobar2000 and long folder/file name handling

Reply #8
could you please explain UNC and how to use it? I didn't even understand the wikipedia article... :/

UNC is mostly used for windows SMB networking, like \\computer\networkshare
but you can also access directories on your local machine, its just a different way to read/write the files then.
while the normal way is through the windows API, which has this 255 charcter limit, going through UNC doesn't have this limitation.
(keep in mind: not the filesystem has this limitation, its the API which foobar (and pretty much everything else) uses to read/write the files)

i don't know how foobar supports those local UNC paths though.
just did some fiddling around, when i added \\?\C:\Music\ in media library, it always displayed as C:\Music\, so no notable change.
adding \\sighunter\c$\Music however worked fine, but i don't know if that is run through SMB and therefore a performance impact happens

Foobar2000 and long folder/file name handling

Reply #9
\\?\ is used automatically.

Foobar2000 and long folder/file name handling

Reply #10
OK I give up.
I still don't know how to "use" UNC. I just read it starts with \\?\ but I don't understand how to "activate" the usage of UNC, I don't know if it's compatible with everything else on Windows and so on...
...and what is \\sighunter\?

Foobar2000 and long folder/file name handling

Reply #11
...and what is \\sighunter\?

my name and an example of a windows networkshare assuming the computername is "sighunter", to state my case. \\windowscomputer\shareddirectory would work too ofcourse

Foobar2000 and long folder/file name handling

Reply #12
As kode54 said, foobar2000 will automatically use the \\?\ prefix which tells the operating system to handle the path differently. Most importantly, the entire path is no longer restricted to 259 characters (including the drive letter) but may be up to 32000 (+something) characters long. A single path component - i.e. the file name or a directory name - may be up to 255 characters long. Within these limits foobar2000 (and the operating system) are able to handle file paths. Usually you are not so lucky with other applications which may refuse certain operations on a file if the path length exceeds 259 characters. Even stranger, the same operations may work sometimes and sometimes not depending on whether the application uses a relative or absolute path to the file. The last time I experimented with longer than usual file names, even Windows Explorer did not handle UNC path. IIRC it would refuse to rename a file but had no problems moving the containing directory.

Bottom line: UNC path allow the use of longer file names but be prepared that some applications might not be able to handle them.

Foobar2000 and long folder/file name handling

Reply #13
For such issues, use LongPathTool, it works good!

Foobar2000 and long folder/file name handling

Reply #14
I don't think UNC is a good solution. I don't want to mess up my files for any other app/software... stupid Windows.

I'll go with shortening instead. Thanks for helping. I still think it is a task, Foobar should perform automatically or at least optionally. But I'm not complaining about this great piece of software.