Rename "Firstname Lastname" to "Lastname, Firstname"

Any questions? Need some help?
Post Reply
Yellowbird
Posts: 19
Joined: 10 Apr 2020, 06:02

Rename "Firstname Lastname" to "Lastname, Firstname"

Post by Yellowbird »

Hi rednoah,

How will it be possible while using the [Plain File Mode] to get a hardlink to the proper folder when the naming goes from "Firstname Lastname" to "Lastname, Firstname" ?
Jeff Rovin - [Tom Clancy's Op-Center 21] - Tom Clancy's Op-Center- Call of Duty.epub

Code: Select all

{drive}/{"media"}/{"books"}/{fn.match(/(.*) (.*)/).replace(/\2 \1/)}/{fn}
The end-result I would like it to be: /media/books/Rovin, Jeff/Jeff Rovin - [Tom Clancy's Op-Center 21] - Tom Clancy's Op-Center- Call of Duty.epub

Image
User avatar
rednoah
The Source
Posts: 22805
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename "Firstname Lastname" to "Lastname, Firstname"

Post by rednoah »

e.g.

Code: Select all

"Jeff Rovin".replaceFirst(/(\S+) (\S+)/, /$2, $1/)

Code: Select all

Rovin, Jeff
:idea: Please read the FAQ and How to Request Help.
Yellowbird
Posts: 19
Joined: 10 Apr 2020, 06:02

Re: Rename "Firstname Lastname" to "Lastname, Firstname"

Post by Yellowbird »

Great.
Almost there.
I need the folder name only and it needs to be Lastname, Firstname and nothing else from the filename.

Code: Select all

{drive}/{"media"}/{"books"}/{fn.replaceFirst(/(\S+) (\S+)/, /$2, $1/)}/{fn}
User avatar
rednoah
The Source
Posts: 22805
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename "Firstname Lastname" to "Lastname, Firstname"

Post by rednoah »

e.g.

Code: Select all

"Jeff Rovin XYZ".replaceFirst(/(\S+) (\S+).*/, /$2, $1/)
:idea: Please read the FAQ and How to Request Help.
Yellowbird
Posts: 19
Joined: 10 Apr 2020, 06:02

Re: Rename "Firstname Lastname" to "Lastname, Firstname"

Post by Yellowbird »

Wow, you truly nailed it!
This is exactly what is needed. :D
I will keep on learning.
Thank you, very much.
Clarar1
Posts: 1
Joined: 22 Sep 2023, 06:43

Re: Rename "Firstname Lastname" to "Lastname, Firstname"

Post by Clarar1 »

Yellowbird wrote: 01 Nov 2022, 12:27 Great.
Almost there.
I need the folder name only and it needs to be Lastname, Firstname and nothing else from the filename.

Code: Select all

{drive}/{"media"}/{"books"}/{fn.replaceFirst(/(\S+) (\S+)/, /$2, $1/)}/{fn}
Hi friend
Extracting just the folder name as "Lastname, Firstname" from a filename is a specific file management task.Free Fire name
Post Reply