When reading in image files from a folder vbscript seems to read them in in random order even when the files are arranged alphabetically. To get round this I have had to read in a specific image on its own, display it then read in those left in the folder and subsequently displayed them individually. Can anyone tell me if it is possible to make vbscript deliberately process first the specific image file of your choice out of a folder of files before the others and how it can be done. I used "for each fil in Fld.Files" to cycle through the files in the folder. If I were to use an array, how could I ensure that that specific image would be the first image. Would I need to sort the array having judicially named that specific file to ensure that it was position 0 in the array?
Asked
Active
Viewed 54 times
0
-
The FSO gives you the files in the order listed in the folder. On NTFS this is alphabetical. On Fat in the order created although deleted files are filled in. Where are your files coming from. – Lundt Sep 05 '22 at 23:03
-
Thanks @Lundt. I had forgotten about that difference between NTFS and FAT. It sounds like Col is reading from a volume that is not returning the files in alpha order, such as a FAT32 flash drive. – LesFerch Sep 06 '22 at 03:27
-
I added an additional answer at the duplicate link that puts the files into an array in whatever sort order you can do with a `DIR` command. If you want the results in a *scripting dictionary*, see the accepted answer at that same link. – LesFerch Sep 06 '22 at 04:04
-
@LesFerch. The files are in a laptop folder and though I sort the contents of that folder using explorer or use the cmd to do it it still does not process the file of my choosing first. I noted what you said earlier and think that my best solution is, as you said, sorting the files into a text file then reading in the file names from it. That way the file I am interested in will always be dealt with first. Your comment awakened a memory of some long time ago having a similar problem and that was how it was solved - for a playlist. I ought to have learned from that. Appreciated with manythanks – Col Sep 06 '22 at 09:49
-
How you sort the files in File Explorer will make no difference. It's just another app between you and the file system. However, the order they are shown when you do a DIR at a CMD prompt should be the order they get read using FSO. The code I posted for you is [here](https://stackoverflow.com/a/73616528/15764378). Change `Const Order = "/od /tc"` to `Const Order = "/on"`. If you could post your code in your question, I could take a look and try to replicate your issue. – LesFerch Sep 06 '22 at 13:08