Deleting dates after a selected character

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

Deleting dates after a selected character

Postby NickGeo40 » Tue Jul 02, 2019 7:04 pm

So I'm trying to rename 10K+ map files from USGS. Some have been modified to show a revised date, but I would like to change them back.

The file names look like this
TX_Austin East_106253_1966pr1973_24000_geo

And I want them to look like this
TX_Austin East_106253_1966_24000_geo

Most of the searches I've done just delete everything after a certain character/text string. However, I'd like to remove the "prXXXX", and keep everything else intact, both before that string and after it.
But I haven't found a wildcard type effect that would allow me to do that. Most of what I've found has been removing everything after a certain character/text string.

I appreciate any assistance with this!
NickGeo40
 
Posts: 3
Joined: Tue Jul 02, 2019 6:57 pm

Re: Deleting dates after a selected character

Postby therube » Tue Jul 02, 2019 8:01 pm

Are XXXX always numbers?
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Deleting dates after a selected character

Postby therube » Tue Jul 02, 2019 8:03 pm

Try...

1:RegEx
Code: Select all
Match:  (.*?)(pr\d\d\d\d)(.*)
Replace:  \1\3
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Deleting dates after a selected character

Postby NickGeo40 » Tue Jul 02, 2019 10:37 pm

That did it! Thank you. And yes, the XXXX is always numbers/years

I am a total novice at this program. Is there any way you could briefly describe the code you used? I tried something similar to this code but didn't put the "pr" in the right location.

Thanks again
NickGeo40
 
Posts: 3
Joined: Tue Jul 02, 2019 6:57 pm

Re: Deleting dates after a selected character

Postby therube » Wed Jul 03, 2019 1:30 am

Code: Select all
(.*?)   (pr\d\d\d\d)   (.*)
\1      \2                  \3


\1 - Match anything, non-greedily
\2 - up to the first instance of the string "pr" followed by 4 digits "####"
\3 - match everything else

And when you write it back out, you include \1 and \3, skipping \2, that part that you don't want.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Deleting dates after a selected character

Postby therube » Wed Jul 03, 2019 1:31 am

(See that. The ability to edit might have ended up with things lined up a little better ;-).)
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Deleting dates after a selected character

Postby NickGeo40 » Wed Jul 03, 2019 1:03 pm

I see. That's very informative. Thank you again!
NickGeo40
 
Posts: 3
Joined: Tue Jul 02, 2019 6:57 pm


Return to BRU Support