Changing Case of Foldername via Scripting?, How to change an existing Windows Foldername via Scripting? |
Please read foobar2000 Tech Support Forum Rules before posting and comply with all the points.
Failure to provide all the information pointed out in the above document in your post is considered wasting other people's time and in extreme cases will lead to your topic getting locked without a reply.
See also: Hydrogenaudio Terms of Service.
![]() ![]() |
Changing Case of Foldername via Scripting?, How to change an existing Windows Foldername via Scripting? |
Dec 28 2010, 02:57
Post
#1
|
|
![]() Group: Members Posts: 164 Joined: 10-February 07 From: kölle an rhein Member No.: 40490 |
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? |
|
|
|
Jan 1 2011, 19:54
Post
#2
|
|
|
Group: Members Posts: 133 Joined: 27-November 10 From: Earth Member No.: 86055 |
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. -------------------- try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb |
|
|
|
Jan 1 2011, 20:53
Post
#3
|
|
![]() Group: Members Posts: 164 Joined: 10-February 07 From: kölle an rhein Member No.: 40490 |
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 :-) |
|
|
|
Jan 2 2011, 13:15
Post
#4
|
|
|
Group: Members Posts: 133 Joined: 27-November 10 From: Earth Member No.: 86055 |
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. This post has been edited by matav: Jan 2 2011, 13:16 -------------------- try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb |
|
|
|
Jan 2 2011, 14:14
Post
#5
|
|
![]() Group: Members Posts: 164 Joined: 10-February 07 From: kölle an rhein Member No.: 40490 |
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 $strcmp(X,Y) %directoryname% $directory(X), $directory(X,N) $directory_path(X) but "do the necessary" ? |
|
|
|
Jan 4 2011, 07:35
Post
#6
|
|
|
Group: Members Posts: 105 Joined: 22-December 07 Member No.: 49766 |
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 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 "$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 "$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
|
|
|
|
Jan 4 2011, 19:45
Post
#7
|
|
|
Group: Members Posts: 133 Joined: 27-November 10 From: Earth Member No.: 86055 |
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, %directoryname% won't be of much use.so that i could to something with these guys: CODE $strcmp(X,Y) %directoryname% $directory(X), $directory(X,N) $directory_path(X) 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 $if($strcmp($directory(%path%,2),%artist%),same,not same) anyways... this code doesn't do anything to solve your issue//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" 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 -------------------- try my portable foobar theme -- eXdb v4d
http://bit.ly/matavfb |
|
|
|
Mar 31 2011, 20:13
Post
#8
|
|
![]() Group: Members Posts: 164 Joined: 10-February 07 From: kölle an rhein Member No.: 40490 |
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 :-) |
|
|
|
Mar 31 2011, 20:20
Post
#9
|
|
|
Group: Super Moderator Posts: 4353 Joined: 23-June 06 Member No.: 32180 |
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. (followed by renaming back, I presume)%artist%\%album% would become %artist%x\%album%x or somewhat 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. This post has been edited by dv1989: Mar 31 2011, 20:31 |
|
|
|
Mar 31 2011, 21:18
Post
#10
|
|
![]() Group: Members Posts: 164 Joined: 10-February 07 From: kölle an rhein Member No.: 40490 |
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. (followed by renaming back, I presume)%artist%\%album% would become %artist%x\%album%x or somewhat 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$" ....) |
|
|
|
Apr 1 2011, 04:07
Post
#11
|
|
![]() Group: FB2K Moderator Posts: 4321 Joined: 1-November 06 From: Cincinnati Member No.: 37036 |
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.
-------------------- "It must be 'Take A Worm For A Walk' week!"
|
|
|
|
Apr 1 2011, 09:01
Post
#12
|
|
![]() Group: Members Posts: 164 Joined: 10-February 07 From: kölle an rhein Member No.: 40490 |
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. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 24th May 2013 - 17:39 |