A quick search would have shown you this thread
Read up pathsubstitution on the kodi.wiki that should answer most of your questions