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: Changing Case of Foldername via Scripting? (Read 4536 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Changing Case of Foldername via Scripting?

hi,

in foobar2000 i automaticly move musicfiles from tag-infos to folders which are named like \\server\share\artist\album

this generally works fine.

problem is, that i'd like to have the same case sensitivity in the folders, as in the tags.
but this only works for non-existing folders.

say,
if i have some musicfiles tagges with the artist "Superartist", *and*
if there is already a "artist"-folder, like "SUPERARTIST",
foobar uses this folder to move the files in and does not change the case sensitivity of this folder.

which might be correct to foobar (and all other windows programs i've seen so far), but how can i tell foobar to do what i want?

it could work, if i could rename the original folder inside the moving process to something other than the original and then let create foobar that "Superartist"-folder and move the files in the newly created one.
but only in theory (and only manually, which is not what i want) :-/

any idea somebody?


Changing Case of Foldername via Scripting?

Reply #1
you already had an idea but anyways...
imo, i don't think foobar was made with an inherent ability to modify folder names.
infact, 'titleformatting' allows only access to, and generally only to the selected track/playing track, metadata.
but if there was a way then even i'd like to know.

Changing Case of Foldername via Scripting?

Reply #2
you already had an idea but anyways...
another idea would be to just add something to the rename schema, so that all affected folders would be "newly" written to the disk.

%artist%\%album% would become %artist%x\%album%x or somewhat, but the problem with this theoretical idea is, that practically, it won't work, if other files like i.e. folder.jpeg are also in the folder. so foobar2000 would not delete the "old" folders and therefore, when removing the "x"-pattern the files would be written to the same "old" folder again.

i'm aware, foobar2000 was not made for solving such problems, i just thought, maybe it is possible :-)

Changing Case of Foldername via Scripting?

Reply #3
definitely possible.

first it will have to check the artist name tag before making folder.
if folder already present, then it will have to do a case sensitive comparison and do the necessary.

but this becomes too much work since files are copied one by one and wrong tags can screw things up.

 

Changing Case of Foldername via Scripting?

Reply #4
first it will have to check the artist name tag before making folder.
if folder already present, then it will have to do a case sensitive comparison and do the necessary.
but this becomes too much work since files are copied one by one and wrong tags can screw things up.


hmmm. i really would like to know, what you mean with "do the necessary".
can you please go into more detail.
case sensitive comarison might be ok for me, because i read anywhere that i can get some directory levels,
so that i could to something with these guys:
Code: [Select]
$strcmp(X,Y)  
%directoryname%
$directory(X), $directory(X,N)
$directory_path(X)

but "do the necessary" ?

Changing Case of Foldername via Scripting?

Reply #5
I'm not sure that changing the case of folder names should be done automatically, as there's always the possibility of having conflicting tags. A possible solution is to have a playlist with the songs which are not in the correct place (according to their tags), and you can then fix either the folder name or the tag.

For example, my music is organised by the titleformatting:
Code: [Select]
E:\Music\[%album artist%\][[$year(%date%) - ]%album%\][Disc %discnumber%[ - %discname%]\][%tracknumber%. ][%artist% - ]%title%

To find songs in the wrong place I'd search for
Code: [Select]
"$strcmp(%path%,E:\Music\[%album artist%\][[$year(%date%) - ]%album%\][Disc %discnumber%[ - %discname%]\][%tracknumber%. ][%artist% - ]%title%.$ext(%filename_ext%))" MISSING


The only real problem is when the titleformatting produces an invalid file name. Mp3tag has a $validate() function which would work nicely, but there's currently no foobar2000 equivalent so if there's lots of false positives or you want an autoplaylist you'll have to add the exceptions to the titleformatting. This will depends on your folder structure and files so I can't really help, but for reference here's what I use:
Code: [Select]
"$strcmp(%path%,E:\Music\$replace([$if($strcmp($right(%album artist%,1),.),$cut(%album artist%,$sub($len(%album artist%),1)),%album artist%)\][[$year(%date%) - ]$if($strcmp($right(%album%,3),...),$cut(%album%,$sub($len(%album%),3)),$if($strcmp($right(%album%,1),.),$cut(%album%,$sub($len(%album%),1)),%album%))\][Disc %discnumber%[ - %discname%]\][%tracknumber%. ][%artist% - ]$replace(%title%,\,-),/,-,?,,:,-,*,x,>,_,<,_,$char(34),'''').$ext(%filename_ext%))" MISSING

Changing Case of Foldername via Scripting?

Reply #6
i meant... it could be possible if someone coded it but not through 'titleformatting'.
i don't see a way, through 'titleformatting', to rename a folder that is already existing.
firstly, how will one retrieve the name of the folder(s) already existing at the destination for comparison purpose?

well.. on a different matter:
...case sensitive comarison might be ok for me, because i read anywhere that i can get some directory levels,
so that i could to something with these guys:
Code: [Select]
$strcmp(X,Y)  
%directoryname%
$directory(X), $directory(X,N)
$directory_path(X)
%directoryname% won't be of much use.
generally it may return the album name (as most have their folder structure as "artist\album\*.whatever") and you are trying to make sure the destination artist folder is an exact match to the artist tag of the selected song.

for fun... in a folder structure as: "...\artist\album\file.mp3"
to check if the folder name for artist is the same as the artist tag of "file.mp3"
Code: [Select]
$if($strcmp($directory(%path%,2),%artist%),same,not same)

//Example (case sensitive)
//success case would be when a file playing is, say:
//having %artist% returning "Phoenix"
//having %path% returning "X:\My Music\Phoenix\Alphabetical\Love for Granted.mp3"
anyways... this code doesn't do anything to solve your issue

but basically, i meant the file operations component would need more coding or an extra component would be needed.
But it will not be equally reliable in every scenario.

--
sorry, i have realized that i tend to confuse alot, including myslef

Changing Case of Foldername via Scripting?

Reply #7
ok, the simplest/fastes method is to move all the files to another drive.
i.e. moving all files in library from X:/foo/bar/music to Y:/foo/bar/music and then back.
this (the changing of the case) will work only if the folders don't exist on the target drive.
another limitation is, that this will only move indexed files and not i.e. folder.jpg's or other files in the folder,
so it might be a bad idea to move all indexed files to drive Y: and then back, because foobar does not delete folders with content, so the folders stay on drive X: and when the folders are moved back, the folders still exist (with the wrong case) and won't be overwritten with the foldrs from drive Y:

so, no automatic solution since now.
a pitty, but not bad :-)

Changing Case of Foldername via Scripting?

Reply #8
It was slightly hack-y, but wouldn’t this work?
another idea would be to just add something to the rename schema, so that all affected folders would be "newly" written to the disk.

%artist%\%album% would become %artist%x\%album%x or somewhat
(followed by renaming back, I presume)
Quote
but the problem with this theoretical idea is, that practically, it won't work, if other files like i.e. folder.jpeg are also in the folder. so foobar2000 would not delete the "old" folders and therefore, when removing the "x"-pattern the files would be written to the same "old" folder again.
Doesn’t ticking “Move entire source folder content” remove this barrier?

If so work, this method would certainly be a lot more parsimonious than moving (actually: copying) all of your files to another drive and back.

Changing Case of Foldername via Scripting?

Reply #9
It was slightly hack-y, but wouldn’t this work?
another idea would be to just add something to the rename schema, so that all affected folders would be "newly" written to the disk.

%artist%\%album% would become %artist%x\%album%x or somewhat
(followed by renaming back, I presume)

yes.


Quote
but the problem with this theoretical idea is, that practically, it won't work, if other files like i.e. folder.jpeg are also in the folder. so foobar2000 would not delete the "old" folders and therefore, when removing the "x"-pattern the files would be written to the same "old" folder again.
Doesn’t ticking “Move entire source folder content” remove this barrier?

If so work, this method would certainly be a lot more parsimonious than moving (actually: copying) all of your files to another drive and back.

funny, i never saw this option “Move entire source folder content”, until now %-)
i guess, that would do the job quite faster, you're right.


the easiest way would be that foobar would just rename all folders twice:

first time (in background, so that the user wouldnt see it): rename source-folder-name -> source-folder-name.$random-anywhat$
second time (just as normal): rename the source-folder-name.$random-anywhat$ -> target-folder-name.
done.

(only drawback i see, is, if foobar crashes between the first renaming and the second, the user might have a folder named "folder.$random-anywhat$" ....)

Changing Case of Foldername via Scripting?

Reply #10
File paths can be kind of screwy when it comes to capitalization (depending on the filesystem).  Generally if a certain path already exists with one capitalization, another won't be made.
elevatorladylevitateme

Changing Case of Foldername via Scripting?

Reply #11
File paths can be kind of screwy when it comes to capitalization (depending on the filesystem).
i never had problems with capitalization while using only one single filesystem/operating system.
i have had some problems with capitalization when i copied/moved files across mixed operating systems with different filesystems.
Generally if a certain path already exists with one capitalization, another won't be made.
i can't agree with that, because i have seen other things (when writing files/folders from windows-file&operating-system to a network nas with a mac-/*nix-filesystem on it) :-) but, you're right, writing the files/folder back to windows won't work.