Started moving code from list_db that resolves target into root,subdir into its own function.