Add " after numbers separated by a x

A swapping-ground for Regular Expression syntax

Add " after numbers separated by a x

Postby craigm » Thu Jun 26, 2014 3:41 pm

I need to add a " after numbers that are separated by an x to indicate dimensions.

Below is a typical file name, currently I have more than 2,500 of these file names.

Jungle Toys, Blocks, Mini Squares, 100 Pieces, Drilled, 0.5 x 1.5 x 11, JU00500.png

I would like to rename the file like this

Jungle Toys, Blocks, Mini Squares, 100 Pieces, Drilled, 0.5" x 1.5" x 11", JU00500.png

I am pulling my hair out, your help will be very welcome.

Craigm
craigm
 
Posts: 2
Joined: Thu Jun 26, 2014 3:32 pm

Re: Add " after numbers separated by a x

Postby truth » Fri Jun 27, 2014 7:21 am

Microsoft considers " an IllegalNameChar, & BRU only runs on Windows.
Windows will simply never accept the " from BRU as a NameChar.
If you have a shell that accepts " and BRU actually runs on it, use:

1Regex match/replace:
(.*, )([0-9\.]+)( x )([0-9\.]+)( x )([0-9\.]+)(, .*)
\1\2"\3\4"\5\6"\7

Otherwise, replace "s with some other char(s)
Last edited by truth on Sat Jun 28, 2014 5:24 am, edited 1 time in total.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Add " after numbers separated by a x

Postby craigm » Fri Jun 27, 2014 2:58 pm

Thank you, I was lost. I need to sit down and study this. I could not have fogured this out on my own.

Thank you very much.
craigm
 
Posts: 2
Joined: Thu Jun 26, 2014 3:32 pm

Re: Add " after numbers separated by a x

Postby CharlesFromVA » Sat Nov 08, 2014 12:43 am

Windows will not allow " as part of a file name, but an inelegant solution would be to use two single apostrophes instead, which it will allow.

Jungle Toys, Blocks, Mini Squares, 100 Pieces, Drilled, 0.5 x 1.5 x 11, JU00500.png could become:

Jungle Toys, Blocks, Mini Squares, 100 Pieces, Drilled, 0.5'' x 1.5'' x 11'', JU00500.png

I think the RegEx (1) would be:
Match:
Code: Select all
(.*, )([0-9\.]+)( x )([0-9\.]+)( x )([0-9\.]+)(, .*)

Replace:
Code: Select all
\1\2''\3\4''\5\6''\7

I wrapped these in code so you could easily see that what's being used is two single apostrophes; it will display exactly like a double quote in the file list.

Hope this helps.
CharlesFromVA
 
Posts: 4
Joined: Sat Nov 08, 2014 12:17 am


Return to Regular Expressions