SOLVED: Remove last 3 characters from a filename

I need to remove the language extension from the filename (eg. first.en ). Tried doing it using the following regex

{{ .File.BaseFileName | replaceRE "\.\w{2}" "" }}

This doesn’t compile.

How can I select the last three characters of the string then ?

The language code for each file is known through the .File.Lang attribute. We could use it for a replacement:

{{ replace .File.BaseFileName (printf ".%s" .File.Lang) "" }}
1 Like

Thanks. That works