The file stampinfo/utils/utils_filenames.py contains a set of very useful functions to store the path and name of a media file and to easily retrieves some parts of its filepath. In particular, in the case of a sequence of images, it can isolate the pattern of the name or the name of an image at a given frame.
Check the function "run_sequence_path_tests" for more details.