How do i make long file names shorter?

Advanced Renamer forum
#1 : 29/11-20 22:12
Shan Jay
Shan Jay
Posts: 8
I have a bunch of folders that contain files name like this (as an example);

this.is.a.long.file.name.docx
this.is.an.even.longer.file.name.docx
this.is.the.longest.file.name.ever.made.docx

So the length of each file name varies. What I would like to do is trim them down to a certain number of characters. Is it possible to rename them in the following way - even if they all have varying lengths?

th.is.a.lo.fi.na.docx
th.is.an.ev.lo.fi.na.docx
th.is.th.lo.fi.na.ev.ma.docx

I would like just 2 letters at the beginning of each word to remain and the rest removed.


29/11-20 22:12
#2 : 30/11-20 00:47
David Lee
David Lee
Posts: 1125
This is an interesting conundrum and was fun to sort out!

Replace: [^\.]{2}\K[^\.]*(\.|$)
With: \1
Occurrence: All
Use regular expressions

[^\.]{2} matches two non-dot characters.

\K instructs the regex not to include the previously matched characters in the final match (so they are not removed).

[^\.]*(\.|$) matches any number of non-dot characters up to and including a dot or the end of the filename and the parentheses mean that the final matched character (dot or null) is saved as \1.

The match repeats until the end of the filename is reached.




30/11-20 00:47 - edited 30/11-20 10:12
#3 : 01/12-20 21:24
Shan Jay
Shan Jay
Posts: 8
Reply to #2:

Thanks, worked perfectly!


01/12-20 21:24