a linux version using find
to list files and head
to take the first n
.
dir = "/path"
StringSplit[
RunProcess[
{"/bin/sh",
"-c",
"find "<>dir<>" -maxdepth 1 -type f | head -10"
},"StandardOutput"]]
note find
does not return files in any canonical order, you can sort for example,
add | sort
in front of | head
Note FileNames[][;;10]]
is a good bit faster by my testing, but I don't have a folder with a million files to test it on.