1

I would like to replace in a lot of filenames, the Greek capital vocals with tonos, with the ones without it:

Ά > Α
Έ > Ε
Ή > Η
Ί > Ι
Ό > Ο
Ύ > Υ
Ώ > Ω

I know how to replace them one by one, but I think RegEx is the best approach, to replace all of them at once. Can someone help me with the syntax, please? Thanks.

Toto
  • 19,304
geotso
  • 35

3 Answers3

3

There's no way to do it weith regex as others have said - it's not what their purpose is. I won't go into details as it has been explained well.

If you want to use this software, you can use its Character translations... feature available in Special dropdown.

Simply add some pairs into the window, such as:

Ά=A
Ή=Η
Ώ=Ω

etc., where = is a separator of target and replacement and each entry is in a new line. Then check the Character translations checkbox and run it on your files: Checkbox

Destroy666
  • 12,350
1

There is no syntax for that. While a regex can be used to match all of them, it won't really help much with replacement – that in itself is already outside of what a regex does; there is no regex syntax to specify what which match should be replaced with. The program that does the regex match still needs to "manually" map each match to its replacement.

In short, it depends on the multi-rename tool and not on the regex.

If this were on Linux, I would use perl-rename (aka prename) as it's arbitrarily programmable, though in this case the simplest option of chaining multiple regular substitutions would do the job. (Perl also has a character substitution operator y/// that looks like regex but isn't.)

prename "s/Ά/Α/g; s/Έ/Ε/g; s/Ή/Η/g; s/Ί/Ι/g; s/Ό/Ο/g; s/Ύ/Υ/g; s/Ώ/Ω/g" ./Docs/*.pdf
prename "%r = ('Ά' => 'Α', 'Έ' => 'Ε', ...); s/[ΆΈ...]/\$r{\$&}/ge" ./Docs/*.pdf
grawity
  • 501,077
1

Well if you don't mind using powershell. It is also included in Windows you could use something like this:

get-childitem *.txt | Rename-Item -NewName {($_.name).replace('Ά','A').replace('Έ','E').replace('Ή','H').replace('Ί','I').replace('Ό','O').replace('Ύ','Y').replace('Ώ','Ω')}