How to remove Multiple length trailing characters?

A swapping-ground for Regular Expression syntax

How to remove Multiple length trailing characters?

Postby upgraders » Wed Apr 09, 2014 1:32 pm

I have a 4 deep Folder structure with about 40,000 files

Root Folder
Folder 1
Folder 1A
Folder 1AB
Folder 2
Folder 2A
Folder 2AB
Folder 3
Folder 3A
Folder 3AB

Inside this structure are files that are named respectively like this:

103.06.00_9.JPG
103.06.00_10.JPG
103.06.00_119.JPG

###.##.##_#.jpg or ###.##.## _##.jpg or ###.##.## _###.jpg

The # preceding the underscore are in this format ###.##.##

The number after the underscore in each folder starts with 1 and continues the count for all of the files. I don't think any go over 3 digits.

What I need to do is delete the underscore and the following numbers for each file.

So the resulting example above would look like this:

103.06.00.JPG
103.06.00.JPG
103.06.00.JPG

In the (remove 5) section I can Crop after _ but then that leaves the Underscore it would be perfect if there was a "Crop After and Including" I don't want to have to run two routines over 40,000 files to remove the underscore.

If I use the Remove section and select FROM 10 to something like 14 then it looks like it works, should I assume that using 14 or higher is okay?


I don't fully understand the RegEx section or the Repl I tried under the Repl _$ to replace with nothing any help would be great as I want to run this as a batch rename over all of the folders at once.

Thanks!
upgraders
 
Posts: 1
Joined: Wed Apr 09, 2014 1:25 pm

Remove trailing _Numbers

Postby truth » Wed Apr 09, 2014 5:19 pm

Going by your examples, removing _#'s would create alot of duplicate filenames,
so you'd need more settings to create unique NewNames??
Also, I assumed that .## _ should'nt have a space ?

If so, you can use:
^(\d\d\d\.\d\d\.\d\d)_\d+$
\1


If OrigNames have AlphaChars before _:
(.+)_\d+$
\1

The 1st regex only matches filenames as described in example
No-limit was placed on how many numbers may follow after _

The 2nd matches any filename ending as _#'s & crops it away.
If you need anything more specific, just post back with details.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions