Creative use of the Parse Path tool should extract the variables you need. Then, set these variables as preconditions to the tool that creates the output data and include those path variable names in the output path for that tool (surrounded by % signs, for example %outpath%/%outname%).
Hope this helps.