taking a part of string from a given path

Hi
I have two path as follows

system/console/bin/code/sample/testfile.txt
system/console/bin/database/files/new/dbfile.txt

I need the output as
code/sample in first case
database/files/new in second case

That is I am omitting system/console/bin and the filename(s) in both the cases

Can you please help
Thanks in advance
Suresh

file=system/console/bin/code/sample/testfile.txt

temp=${file#system/console/bin/}
printf "%s\n" "${temp%/*}"

Awesome thank you very much