Moving articles (a, an, the) from the end of the file

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Moving articles (a, an, the) from the end of the file

Postby dj.aida » Fri Oct 07, 2011 3:30 pm

Hello, I started using this program recently, and have been using it mostly to prefix the folder name to my files. I have discovered there there are some files that have an article (a, an, the) at the end of the file, before the extension. Here is the example:

Fiction > Genre > Author > Author - Story Title, A.epub
Fiction > Genre > Author > Author - Story Title, An.epub
Fiction > Genre > Author > Author - Story Title, The.epub

How do I remove the comma and space, and move the article in front Story Title and make sure it is separated by a space from the Story Title? I.e.

Fiction > Genre > Author > Author - A Story Title.epub
Fiction > Genre > Author > Author - An Story Title.epub
Fiction > Genre > Author > Author - The Story Title.epub

Thank you in advance!
dj.aida
 
Posts: 1
Joined: Fri Oct 07, 2011 3:24 pm

Re: Moving articles (a, an, the) from the end of the file

Postby Glenn » Mon Oct 10, 2011 5:21 pm

One way this can be solved is using the first section (Regex(1))of Bulk Rename.
Assuming that there is only one hyphen and one comma in each filename placed as in your examples, the following will work:
Regex(1)
Match:([^-]+)-([^,]+), (.+)
Replace:\1- \3\2

Include Ext. is unchecked.

It could also be solved using
(.*)-(.*), (.*)
but using (.*) is not my first choice because (.*) always matches everything to the end of the filename and then does a lot of backtracking to allow following parts of the regex to match.
In this case, using [^-] and [^,] solves the regex in 10 steps.
Using (.*) solves each one in about 80 steps because of all the backtracking.
This can cause a significant difference in speed if you are renaming thousands of files.

Cordially,
Glenn
Glenn
 
Posts: 28
Joined: Fri Apr 14, 2006 4:53 pm
Location: Winnipeg, Canada


Return to BRU Support