Set the directory with your files
dataDirectory=NotebookDirectory[]<>"data";SetDirectory[dataDirectory];
Get the filenames
files=FileNames[All,Directory[]];
In[]:=
files
Out[]=
{/home/estevao/Desktop/teste/data/bgh.12mm15mm10nm.dat,/home/estevao/Desktop/teste/data/bgx.22mm35mm12nm.dat,/home/estevao/Desktop/teste/data/xtc.32m5km12mm.dat}
Remove the directory and extension from the filenames
In[]:=
names=StringReplace[files,(dataDirectory<>"/"|".dat")""];
Get each pattern from the filename
In[]:=
infos=StringCases[names,x:DigitCharacter..~~y:LetterCharacter..]
Out[]=
{{12mm,15mm,10nm},{22mm,35mm,12nm},{32m,5km,12mm}}
We can split the number from the unity
In[]:=
infos2=StringCases[#,{x:DigitCharacter..,y:LetterCharacter..}]&/@infos
Out[]=
{{{12,mm},{15,mm},{10,nm}},{{22,mm},{35,mm},{12,nm}},{{32,m},{5,km},{12,mm}}}
And then.. we can convert all of them
In[]:=
result=UnitConvert[Quantity[#[[1]],#[[2]]],"mm"]&/@#&/@infos2
Out[]=
,,,,,,,,
You can also multiply all of them
In[]:=
Apply[Times,#]&/@result
Out[]=
,,