12.10.5 beta has some scripting changes to make the path modifications you're looking for easier within script code:
If you don't want to use scripting (as in JScript or VBScript), you may also find the noroot and subdir modifiers for the Codes for passing filenames useful.