#1 : 23/11-23 12:51 Narayan
Posts: 3
|
My file names have this format:
<Title> - <subtitle> Where both <title> and <subtitle> have multiple words, and there may be hyphens in them. The separator between the title and subtitle is a hyphen with spaces on both sides. But all other hyphens will not have spaces on both sides. (These are regular English words or expressions, such as "non-stop", "step-by-step", etc.) I want to first force lowercase for the entire name, and then make upper case for the first letters of the Title and Subtitle. All the hyphens that do not have spaces on each side should be ignored. How do I achieve this? |
#2 : 25/11-23 10:28 Eugene
Posts: 2
|
I'd do it with a script. Something like this:
``` javascript //function (index, item) { var first = item.name.split("-")[0].trim().toLowerCase() first = first.charAt(0).toUpperCase() + first.slice(1) var second = item.name.split("-")[1].trim().toLowerCase() second = second.charAt(0).toUpperCase() + second.slice(1) return first + " - " + second; //} ``` This does: "firSt - secOnD.txt" -> "First -Second.txt" Just to be safe, ensure that "Apply to:" is set to "Name"... otherwise it'll erase the extension. Or, if you don't, you'll just need to apply it later: ``` javascript ... return first + " - " + second + item.extension; ``` |
#3 : 29/02-24 08:16 Delta Foxtrot
Posts: 357
|
Reply to #1:
Just for information's sake, this works (at least in v. 3.94): Replace method- Replace: (.)(.*) - (.)(.*) Replace with: \U1\L2 - \U3\L4 or R: ^(\w)(.*) - (\w)(.*) RW: \I1\L2 - \I3\L4 (regex on for either of course) Best, DF |