IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Replacing slash in filename?
Tigermess
post Apr 20 2012, 20:34
Post #1





Group: Members
Posts: 65
Joined: 28-October 11
Member No.: 94746



I'd like to replace forward slash '/' which is in the TITLE, to be presented in filename otherwise (eg. like ampersand '&' or colon ','). I use File Operations dialog but can't force foobar2000 to replace it with anything else than short dash '-'. I am trying string like
CODE
$replace(%title%,/,)
, surronding slash with different quotes, preceding it with other slashes, writing it as $char(i-already-forgot-the-number) but without success. Did I do something wrong? Or is it hardcoded? :-(
Go to the top of the page
+Quote Post
derty2
post Apr 20 2012, 23:24
Post #2





Group: Members
Posts: 580
Joined: 5-June 11
Member No.: 91257



$replace(%title%,'/',,)
all slashes found in %title% tag will be removed and replaced by nothing.

$replace(%title%,'/',,'&',,)
all slashes and ampersands found in %title% tag will be removed and replaced by nothing.

$replace(%title%,'/','&')
all slashes found in %title% tag will be replaced by ampersand.

$replace(%title%,'///','&','//','&','/','&')
all triple slashes and double slashes and single slashes found in %title% tag will be replaced by single ampersand.
Go to the top of the page
+Quote Post
Tigermess
post Apr 22 2012, 01:40
Post #3





Group: Members
Posts: 65
Joined: 28-October 11
Member No.: 94746



Hi, thanks, I tried the strings you sent, unfortunately it doesn't work :-( Does it work for you in File Operations?
Go to the top of the page
+Quote Post
derty2
post Apr 22 2012, 09:51
Post #4





Group: Members
Posts: 580
Joined: 5-June 11
Member No.: 91257



I assume the task is this: Right-click context menu -> File Operations -> Rename to...
Would you like share the exact details of "it" in "unfortunately it doesn't work" so I can also get a handle on your problem ?
Go to the top of the page
+Quote Post
Tigermess
post Apr 24 2012, 18:37
Post #5





Group: Members
Posts: 65
Joined: 28-October 11
Member No.: 94746



Of course. I have MP3 file with "test title 1 / test title 2" as TITLE tag.

I run Rename to... the way you wrote. I fill the File name pattern as can be seen in the screenshot.



In the preview, you can see that slash was replaced with dash instead of ampersand. After clicking run, file is renamed with dash instead of ampersand. The string and everything is correct - proof is in following screen:



See that I exchanged slash for "test title 2" - and this expression is replaced without any problem. Any other expression or character is replaced without problem, only slash is hard-replaced by dash and this can't be changed (backwards slash is possibly unchangeable too, I didn't test it yet).
Go to the top of the page
+Quote Post
yanni
post Apr 24 2012, 19:43
Post #6





Group: Members
Posts: 82
Joined: 3-June 06
Member No.: 31415



QUOTE (http://www.foobar2000.org/FAQ#renaming_files)
Why can't I use $replace() to create custom substitution schemes for characters that can't be used in file names?
Invalid file name characters - such as slashes or backslashes - are replaced before metadata originating from the file is processed by title formatting functions. This is necessary to allow slash or backslash characters placed by you in your file name formatting pattern to be interpreted as path delimiters without the side effect of each slash contained in metadata fields included in your file name formatting pattern being interpreted as a path delimiter as well.

QUOTE (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:File_operations)
Beginning in 0.9.6.4, symbols which are invalid in folder and file names such as / \ |: get replaced by a -, * gets replaced by x, " gets replaced with '', and ? < > get replaced by an _.

As you can see, this behaviour is intended. Only workaround I can see right now, is to replace the hyphen-character (-) instead.
Go to the top of the page
+Quote Post
Dynamic
post Apr 26 2012, 10:55
Post #7





Group: Members
Posts: 796
Joined: 17-September 06
Member No.: 35307



Other option is to create a new tag containing your new modified filename using the string handling you desire then read that tag into the rename dialogue instead of %title%

Perhaps easiest is to temporarily change %title% tags in the tag editing scripts to replace all '/' with some other character that doesn't occur legitimately in your playlists
(there's a lot in the Windows character set,
such as ALT+0182 (hold down alt, use the number pad to type 0182 then release, or use Windows Character Map in Programs/Accessories/System Tools) and this character is legal in Windows filenames, so fb2k's renamer should leave it alone.
which gives the Pilcrow symbol, )
then do the rename, replacing with &
then re-edit the %title% tags, replacing all Pilcrows () with forward slashes (/) in the %title% tags to revert to your original tags after the rename.

But for most people they won't be so worried about the detail so long as the tags show the desired info and the filename is intelligible enough to get the gist, a reason I support this automated behaviour in fb2k which makes life a lot easier.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 1st August 2014 - 11:07