Try :help expand()
This section of the docs seems especially relevant to you:
Modifiers:
:p expand to full path
:h head (last path component removed)
:t tail (last path component only)
:r root (one extension removed)
:e extension only
Example: >
:let &tags = expand("%:p:h") . "/tags"
Note that when expanding a string that starts with '%', '#' or
'<', any following text is ignored. This does NOT work: >
:let doesntwork = expand("%:h.bak")
Use this: >
:let doeswork = expand("%:h") . ".bak"
It looks like your trailing (and possibly leading) strings won't work with expand()
.
This does work though:
:echo "foo" . expand("%:p:r:s") . "bar"
Possibly you can rework your script so wildcards are expanded before they are combined with other strings. Alternatively you could try to split the concatenated string, expand the wildcards, then re-concatenate.