Add Space After 8 Digit File Name

A swapping-ground for Regular Expression syntax

Add Space After 8 Digit File Name

Postby Shawnny Canuck » Thu Aug 07, 2014 6:46 pm

Hello,

I asked a question a few weeks ago and the community here is a great help so I have another quick question. I have a large number of files saved using the following naming convention:

12345678- Title 1 - Title 2

And I want to use RegEx to add a space after the last number so the new file name will be as follows:

12345678 - Title 1 - Title 2

Basically, I want to add a space between the 8 and the -

The numbers are all different values (although I don’t think that probably matters) and they are always 8 digits long. Also, if possible I would like to find a solution that only involves using RegEx and not just the options present in BRU as I want to run this as a batch rename in another program. Thanks everyone.
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm

Re: Add Space After 8 Digit File Name

Postby Stefan » Fri Aug 08, 2014 10:05 pm

 

FROM:
12345678- Title 1 - Title 2.ext
TO:
12345678 - Title 1 - Title 2.ext

USE:
RegEx(1)
Find: (\d{8})(- .+)
Repl: \1 \2






 
You cannot make another post so soon after your last.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Add Space After 8 Digit File Name

Postby Shawnny Canuck » Tue Aug 12, 2014 5:43 pm

Stefan,

You are the man. You have single handily helped me come up with a workflow that has saved my coworkers and I endless hours of work. Not to mention the amount of time it would have taken me to become a RegEx expert like yourself. I hope you don’t mind me asking you one final question as this is the last piece I require to complete the renaming process.

Now that I have my files named correctly the last step I need is to add 01 – to the front of certain files. The find is easy it’s the replace that I could use your expertise. Using my previous example I would to find a specified title within my string and for all instances when that word is found add 01 – to the begging of the strong.

Example:

From:
12345678 - Title 1 - Title 2.ext

To:
01 - 12345678 - Title 1 - Title 2.ext

The reason I am adding 01 – to certain files is because they are required to be at the top within windows explorer for quick access. As mentioned I have no clue how the replace field should look:

Find: Title 2
Repl: ???

Thank you kind sir.
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm

Re: Add Space After 8 Digit File Name

Postby Stefan » Tue Aug 12, 2014 6:26 pm

Shawnny Canuck wrote: I would to find a specified title within my string and for all instances when that word is found add 01 – to the begging of the strong.

Example:

From:
12345678 - Title 1 - specified title.ext

To:
01 - 12345678 - Title 1 - specified title.ext


You can utilize regular expression to match the whole file name and see if it contains the wanted "specified title" literally.
BRU will only rename those files which will match to the reg exp.

So try

RegEx(1)
Find: ^(.+specified title )$
Repl: 01 - \1




Explanation:
^$ will match at the begin and end of the string
.+ will match one-or-more (+) of any sign (.)
specified title is your literally entered text and will match exactly that
The (...) parenthesis will store what was matched for later reuse by the "\1"
"01 - " is literally entered text at the replacement.     "\1" will insert was matched at the find process.





 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Add Space After 8 Digit File Name

Postby Shawnny Canuck » Tue Aug 12, 2014 9:36 pm

Your solution works beautifully in BRU but when I copy it over to the Adobe Plug-In I am using it leaves a lot of spaces at the end of my bookmark. For example:

01 - 12345678 - Title 1 - Title 2_____________________________.ext

Note: The underscore represents blank space.

No clue why it’s adding all those spaces at the end of my string.
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm

Re: Add Space After 8 Digit File Name

Postby Shawnny Canuck » Wed Aug 13, 2014 5:47 pm

I just wanted to thank you again Stefan I can confirm that the plug-in is what is causing the issue with the added spaces. I have sent tech support an email. My solution has now evolved outside of BRU and I don't want to clutter these forums with unrelated content. You my friend deserve to be paid for all the consulting you provided me haha.
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm

Re: Add Space After 8 Digit File Name

Postby Stefan » Wed Aug 13, 2014 7:32 pm

Thanks for the feedback!
We guessed such like this too.
And for the paying, ... just help two others too. And spread the word about BRU.



 
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Re: Add Space After 8 Digit File Name

Postby Shawnny Canuck » Wed Aug 13, 2014 9:48 pm

I most definatly will. In fact, I already have installed it on all the machines in my office and I plan to take a RegEx course online. Cheers.
Shawnny Canuck
 
Posts: 18
Joined: Wed Jul 30, 2014 7:15 pm


Return to Regular Expressions