Removing spaces between date

Advanced Renamer forum
#1 : 24/05-21 16:08
Jan Spatschek
Posts: 1
Hello!

I have files that look like this:

2021_04_21_Word_Word_Word

I want to change them to look like this:

20210421 Word Word Word

How would I go about doing this?

Removing all underscores and replacing them with spaces results in YYYY MM DD Word Word Word.

After that, I can't figure out how to remove the spaces only between the YYYY MM DD.

Thanks in advance!

edited: 24/05-21 16:14
#2 : 24/05-21 17:26
David Lee
Posts: 1125
Do this in two stages using either two Replace methods or two rows in a List Replace method.

(1) Replace: (\d{4})_(\d{2})_(\d{2}) with: \1\2\3
(2) Replace _ with: space
Use regular expressions

(1) above will match dddd_dd_dd explicitly. If your "Word"s can never begin with a digit then you can simplify the first Replace as...

Replace: _(?=\d) with nothing
Use regular expressions

(Replace the remaining "_"s with spaces as before, using (2).)

This uses a "lookahead" - ie "(?=\d)" - which indicates that "_" is only to be matched if it is followed by a digit.

edited: 24/05-21 17:27