The problem, very likely, is that the files are not random but sorted by string name. For example:
Sort@Table[
StringTemplate["``.jpg"]@k
, {k, 30}
]
(* {"10.jpg", "11.jpg", "12.jpg", "13.jpg", "14.jpg", "15.jpg", \
"16.jpg", "17.jpg", "18.jpg", "19.jpg", "1.jpg", "20.jpg", "21.jpg", \
"22.jpg", "23.jpg", "24.jpg", "25.jpg", "26.jpg", "27.jpg", "28.jpg", \
"29.jpg", "2.jpg", "30.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", \
"7.jpg", "8.jpg", "9.jpg"} *)
So you need to generate a file list in order, here some options.
Create list
Table[
Import[StringTemplate["``.jpg"]@k]
, {k, Length[FileNames["*.jpg"]]}
]
Sort FileNames
Import /@ SortBy[FileNames["*.jpg"], ToExpression@StringDelete[#, ".jpg"] &]
Or, adapted from here
Import /@ With[
{fnl = FileNames["*.jpg"]},
fnl[[Ordering[
StringSplit[fnl, x : NumberString :> ToExpression@x][[All, 1]]]]]
]