Insert text into a filename at the second comma

A swapping-ground for Regular Expression syntax

Insert text into a filename at the second comma

Postby jasiha » Tue Oct 16, 2018 10:54 pm

Hi,
I guess it is possible to do this but don't know how...

Filename = Simons,Jaak,Brussels,13011910,Antwerp,25032009.jpg

I want to insert a variable text e.g. (letter) before the second comma.
So: Simons,Jaak (brief),Brussels,13011910,Antwerp,25032009.jpg

Any solution?
Thanks.
Jaak
jasiha
 
Posts: 9
Joined: Tue Aug 28, 2018 2:59 pm

Re: Insert text into a filename at the second comma

Postby Admin » Tue Oct 16, 2018 11:01 pm

Hi, is it always (brief) that needs to be inserted at that position, literally? thanks
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Insert text into a filename at the second comma

Postby jasiha » Thu Oct 18, 2018 11:39 am

No, "brief", "krant" or "prent" are possible.
So I think it should be a variable
Tnx
jasiha
 
Posts: 9
Joined: Tue Aug 28, 2018 2:59 pm

Re: Insert text into a filename at the second comma

Postby Admin » Thu Oct 18, 2018 12:58 pm

OK, how is it decided which file name gets which variable?
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Insert text into a filename at the second comma

Postby jasiha » Thu Oct 18, 2018 5:08 pm

It's my decision to set the word in the variable.
Only the files I selected have to be renamed.
So: x files with the word "brief", other selected files with the word "krant" etc.
Hope this is clear.
Regards.
jasiha
 
Posts: 9
Joined: Tue Aug 28, 2018 2:59 pm

Re: Insert text into a filename at the second comma

Postby jasiha » Sun Oct 21, 2018 1:30 am

Maybe to make a clearer.

I have three directories with files like name,surname,birth place,birth date,death place,death date +.jpg

The first needs to be replaced with (brief) before the second comma
The second dir to be replaced with (prent) before the second comma
The third dir to be replaced with (krant) before the second comma

Any solution?

All together some 10,000 files.
jasiha
 
Posts: 9
Joined: Tue Aug 28, 2018 2:59 pm

Re: Insert text into a filename at the second comma

Postby jasiha » Mon Oct 22, 2018 1:50 pm

Admin wrote:OK, how is it decided which file name gets which variable?


The three different files are placed in separate directories.
In the first one I'd like to add (brief) before the second comma
The second (prent)
The third (krant)
jasiha
 
Posts: 9
Joined: Tue Aug 28, 2018 2:59 pm

Re: Insert text into a filename at the second comma

Postby Admin » Tue Oct 23, 2018 12:08 am

Please try:

RegEx (1)
Match : ([^,]*),([^,]*),(.*)
Replace: \1,\2 (brief),\3

change (brief) as needed.

Please preview and test on a copy of the files first.
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm

Re: Insert text into a filename at the second comma

Postby jasiha » Wed Oct 24, 2018 7:28 pm

Admin wrote:Please try:

RegEx (1)
Match : ([^,]*),([^,]*),(.*)
Replace: \1,\2 (brief),\3

change (brief) as needed.

Please preview and test on a copy of the files first.


Hi Admin!
Great! The ultimate solution. Thanx a lot.
jasiha
 
Posts: 9
Joined: Tue Aug 28, 2018 2:59 pm


Return to Regular Expressions