Baseball Pictures rename (switch names)

A swapping-ground for Regular Expression syntax

Baseball Pictures rename (switch names)

Postby MJHJR » Fri Feb 13, 2015 1:36 am

I have thousands of BB pictures for use in computer text games. I want them all to be last name first and have changed thousands.
The ones I am having trouble with are with the team name in them. For example:
Mickey_Mantle.jpg changes easy to Mantle_Mickey.jpg
Some are : Mickey_MantleNYY.jpg and some are : Mickey_MantleNYY_1956.jpg
How do I get them all to read : Mantle_Mickey_NYY_1956.jpg
How do I separate the NYY from Mantle ?

Thanks, Mike Hennelly
MJHJR
 
Posts: 12
Joined: Tue Jan 06, 2009 10:45 pm

Re: BaseballPictures rename

Postby Admin » Tue Feb 17, 2015 1:44 pm

Hi, is NYY always attached to the name to switch?
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: BaseballPictures rename

Postby MJHJR » Tue Feb 17, 2015 9:05 pm

Yes, the team name is attached to all of the names.
Like COL for the Rockies, PHI for the Phillies , MET for the Mets. CARD for St. Lewis

Mike
MJHJR
 
Posts: 12
Joined: Tue Jan 06, 2009 10:45 pm

Re: BaseballPictures rename

Postby Admin » Tue Feb 17, 2015 11:41 pm

Thanks, how are you changing Mickey_Mantle.jpg into Mantle_Mickey.jpg currently?
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: BaseballPictures rename

Postby MJHJR » Wed Feb 18, 2015 6:05 am

Yes, I have been doing that change on all of the players that have the first name first.

If they are : Mickey_Mantle.jpg - I use: (.*)_(.*) and \2_\1

If they are : Mickey_Mantle_NYY_1956.jpg - I use (.*)_(.*)_(.*)_(.*) and \2_\1_\3_\4

Some have the NYY right next to the last name and that is my problem.

Mickey_MantleNYY_1956.jpg

Thanks, Mike
MJHJR
 
Posts: 12
Joined: Tue Jan 06, 2009 10:45 pm

Re: Baseball Pictures rename (switch names)

Postby Admin » Wed Feb 18, 2015 2:21 pm

For
Mantle_MickeyNYY_1956.jpg
you could use
(.*)_(.*)NYY_(.*)
and
\2_\1_NYY_\3
then the file is renamed to
Mickey_Mantle_NYY_1956.jpg
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Baseball Pictures rename (switch names)

Postby MJHJR » Thu Feb 19, 2015 3:51 am

Thanks a lot !
Now, most of the team names after the player name are three letters: met, cub, phi, col, was, atl, etc

Can the letters ( nny, col, phi, etc ) in the expressions be changed so I don't have to do One at a time ?

Again , Thanks for you help. Mike
MJHJR
 
Posts: 12
Joined: Tue Jan 06, 2009 10:45 pm

Re: Baseball Pictures rename (switch names)

Postby Admin » Fri Feb 20, 2015 3:28 am

This should work:

(.*)_(.*)(NYY|PHI)_(.*)

with

\2_\1_\3_\4

For (NYY|PHI) separate all possible states with | (case sensitive).
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions