I'm sorry if this is a question beyond the scope of TC support It is not specifically about TC but a feature of it. Just say if it is beyond scope and I'll delete the post (if possible?) I'm talking about the Multi Rename Tool here
I have a folder of files with names of undetermined words and I want to insert a dash between the second word and the third thus....
"first second third fourth fifth sixth and so on and so on" and I want to change all the file names to....
"first second - third fourth fifth sixth and so on and so on" - I wonder if the Regex experts here could detail the command to do this? Is it possible? Or should I just do it manually? I HAVE Googled it but not got a satisfactory answer
Thanks in anticipation
Batch change filenames with Regex (insert a dash between second and third word)
Moderators: white, Hacker, petermad, Stefan2
Batch change filenames with Regex (insert a dash between second and third word)
There are 10 types of people in the world,
Those who understand binary and those who don't.
Those who understand binary and those who don't.
Re: Batch change filenames with Regex
FROM:
first second third fourth fifth.txt
TO:
first second - third fourth fifth.txt
- create a backup of that files
- select all wanted files
- open MRT
- Search: ^(.+?)\s(.+?)\s
- Replace: $1 $2 -
[x] RegEx
Explanation:
^(.+?)\s(.+?)\s
^ --- start matching at begin of string
() --- store what is matched for later re-use
. --- match one of any single sign (number, char, dot , dash, space, ...)
+ --- match one-or-more of the expression on the left
? --- match non-greedy (match as few as possible only)
\s --- match one white space
(.+?)\s ---match one-or-more of any sign, but non greedy until an space, and store in capture group
$1 --- give back what is stored in first capture group, counted from the left
You can also use:
- Search: ^(.+?\s.+?)\s
- Replace: $1 -
.
first second third fourth fifth.txt
TO:
first second - third fourth fifth.txt
- create a backup of that files
- select all wanted files
- open MRT
- Search: ^(.+?)\s(.+?)\s
- Replace: $1 $2 -
[x] RegEx
Explanation:
^(.+?)\s(.+?)\s
^ --- start matching at begin of string
() --- store what is matched for later re-use
. --- match one of any single sign (number, char, dot , dash, space, ...)
+ --- match one-or-more of the expression on the left
? --- match non-greedy (match as few as possible only)
\s --- match one white space
(.+?)\s ---match one-or-more of any sign, but non greedy until an space, and store in capture group
$1 --- give back what is stored in first capture group, counted from the left
You can also use:
- Search: ^(.+?\s.+?)\s
- Replace: $1 -
.
Re: Batch change filenames with Regex (insert a dash between second and third word)
Thanks Stefan2 - you really know your Regex
I used your first solution - worked PERFECTLY
Thanks again
I used your first solution - worked PERFECTLY
Thanks again
There are 10 types of people in the world,
Those who understand binary and those who don't.
Those who understand binary and those who don't.