how to cut and delete a part of a folder name

Advanced Renamer forum
#1 : 08/04-16 17:53
Posts: 17
i'm sarching for a solution of the following problem
i have many ebook-folders like this

Dahl, Julia - Rebekah Roberts 01 - Invisible City
Isaacson, Walter - Steve Jobs
Ling, Stir - The Fault In Our Stars - A Letter To Augustus Waters - The Parody
.... and so on
I want to delete the rest of the folder name after the first "-" (dash)
and the "-" itself
so the result should be

Dahl, Julia
Isaacson, Walter
Ling, Stir

i use the
replace mode
(.+) - (.+)
with regular expressions: tick

but that doesn't work with folder names with more than one "-" in it !
could someone help
best regards


08/04-16 17:53
#2 : 08/04-16 23:59
Posts: 92
Reply to #1:
In this case, rather than use the Replace Method, it is simpler to use the 'Remove Pattern' Method:
Pattern: <space>-.+
(where <space> is a single space)
Use regular expressions: Tick

Summary: look for a space followed by a dash followed by any character (at least one), and remove this entire string.

As for your original regex: (.+) - (.+), the reason it does not work when there is more than one dash is that in the first group, the dot (which means any character) is 'greedy' and consumes all characters (including a dash!) leaving the absolute minimum possible to satisfy the rest of the regex ' - (.+)'.

So the trick would be to make it non-greedy by modifying the '+' (which means at least one) quantifier to be '+?'. The ? makes the quantifier non-greedy, so that it stops when it comes cross the first instance of ' -'. The ? is not to be confused with the optional symbol which applies when it is not following a quantifier like '+' or '*', in which case, it modifies the quantifier greedy or not.

So the search string should be: (.+?) - (.+)

08/04-16 23:59 - edited 09/04-16 13:10
#3 : 09/04-16 10:46
Posts: 17
Reply to #2:
Thx a lot for the help and the explanation !
(.+?) - (.+) in Replace Method works perfect

but -- only for understanding:
your favored "Remove Method" with the pattern <space>-.+ seems not to work ?
what i do:
i put "<space>-.+" in the "remove count"-field, leave "starting at"-field empty
and use regular expressions: Tick (I do not know if that is correct !)
the result is: after activating this method the folders in the "new fodernames"-list remain grey



09/04-16 10:46
#4 : 09/04-16 13:10
Posts: 92
Reply to #3:
"your favored "Remove Method" with the pattern <space>-.+ seems not to work ?"

Note that there are two similarly named method: 'Remove' and 'Remove Pattern'. It's not the Remove one, but the Remove Pattern that you should use. Then it should work. Note that <space> should be replaced with one single space. I use that tag here as a literal space is not easy to see.

09/04-16 13:10
#5 : 09/04-16 22:33
Posts: 17
Reply to #4:
Hi !
as my father said before.... "Read first, then ask !!"
it really works with the " Remove Pattern"-Method
Thx a lot again


09/04-16 22:33