Say I have a number of files in a directory at some location (C:\dir1\dir2\dir3...), and I pull an array of strings corresponding to the file names with the command:
fileList = FileNames["*", "C:\\dir1\\dir2\\dir3"]
Here, the files are named with consecutive integers (1 through N) and the output is automatically sorted like the following:
C:\dir1\dir2\dir3\10.tif
C:\dir1\dir2\dir3\11.tif
C:\dir1\dir2\dir3\12.tif
C:\dir1\dir2\dir3\13.tif
C:\dir1\dir2\dir3\14.tif
C:\dir1\dir2\dir3\15.tif
C:\dir1\dir2\dir3\16.tif
C:\dir1\dir2\dir3\17.tif
C:\dir1\dir2\dir3\18.tif
C:\dir1\dir2\dir3\19.tif
C:\dir1\dir2\dir3\1.tif
C:\dir1\dir2\dir3\20.tif
C:\dir1\dir2\dir3\2.tif
C:\dir1\dir2\dir3\3.tif
C:\dir1\dir2\dir3\4.tif
C:\dir1\dir2\dir3\5.tif
C:\dir1\dir2\dir3\6.tif
C:\dir1\dir2\dir3\7.tif
C:\dir1\dir2\dir3\8.tif
C:\dir1\dir2\dir3\9.tif
For any value N, is there an ordering function p I can apply to fileList (using Sort[fileList,p]) to arrange the entries in fileList to obey to proper integer ordering of the file names? Can I supply this ordering function directly to FileNames?
FileBaseNameinstead ofStringDrop[...]. – Leonid Shifrin Sep 17 '13 at 10:54StringDrop. – Leonid Shifrin Sep 17 '13 at 11:03