I have a UWP app that has an option to open an Image Sequence. Typically image sequences are named as follows:
MyImageSequence_00001.png, MyImageSequence_00002.png, ... MyImageSequence_01024.png, MyImageSequence_01025.png,
Generally, these image sequences will be named something like "UniqueFileName_v06" with a frame number like "_0004" following. In a lot of cases you could have multiple image sequences in the same folder but they will have different leading names such as "UniqueFileName_v04_Reflections" or "UniqueFileName_v04_Depth". The starting frame number could be any number and the frame number will increase sequentially to the last frame of the sequence.
I'm currently having the user select all of the files manually as follows:
FileOpenPicker filePicker = new FileOpenPicker();
filePicker.ViewMode = PickerViewMode.List:
filePicker.FileTypeFilter.Add(".png");
filePicker.FileTypeFilter.Add(".jpg");
filePicker.FileTypeFilter.Add(".tif");
files = await filePicker.PickMultipleFilesAsync();
What I am hoping to do is allow a user to open their image sequence by selecting a single image from the sequence in a file picker. So if they were to select "MyImageSequence_00003.png" the app will find and select the rest of the files in the sequence (MyImageSequence 00001-01025) and add them to the filePickerSelectedFilesArray
variable files
.
Secondly, I'd like to generate a composite string name from the list of files. So, generate a name like "MyImageSequence_00001-01025" to identify the image sequence.
Any thoughts on the best way to go about this? Seems like I should use something like the StorageItemsQuery class but unsure if that is the best method nor how to go about it.
Thanks for any help you can provide!
I'm using the following to get the Image sequence name without frame numbers:
File path to input C:\Users\Me\Desktop\MyImageSequenceFolder\MyImageSequence_00001.png
string input = Path.GetFileNameWithoutExtension(fileFromImageSequence.Path);
string pattern = @"\d+$";
string replacement = "";
Regex rgx = new Regex(pattern);
string result = rgx.Replace(input, replacement);
sequenceName = result.TrimEnd('_');
sequenceName output is "MyImageSequence"