General > General Technical Chat
Mysterious USB Stick Sorting Algorithm
(1/4) > >>
IDEngineer:
Years ago, my wife got tired of constantly straightening the framed photos on the living room wall.

"You're an Engineer, fix this!"

So I plumbed in dedicated outlets and hung a pair of flat screen TV's. About once a year, generally near the holiday season when we have folks coming over, I add selected photos from the last year to two USB sticks. The screens rotate the image about every 10 seconds so there's a nice running sequence of stills, about 2000+ photos per screen. It's very popular; people watch the screens for scenes in which they, or people they know, appear and relive the memories.

I'm doing my annual update now, and have rediscovered a strange behavior: The screens display the photos as they were last sorted in Windows Explorer. No, I'm not making that up.

Here's the sequence:

1) I update the photos in the two directories I maintain for this purpose (one for each screen).

2) I delete all existing photos from the USB sticks, which are formatted in FAT32 because that's what the screens require.

3) I copy each directory into its USB stick. There's nothing else on the sticks (to avoid confusing the screens), just the root directory full of JPG's. No thumbs.db, no other directories, nothing.

Here's where it gets interesting. If I view a USB stick using Windows Explorer, the last sorting algorithm controls the order that the flat screen TV's display them. If I sort by name, and then unplug the USB stick and plug it into a TV, the images will be displayed in name order. If I sort by date, they will be displayed by date. If I sort by size, they are displayed in size order.

How is that possible? The USB stick does not appear to have any files on it that would "record" the last sorting choice. Each TV is a standalone device, hanging on the wall, whose only connection to the outside world is its power cord. I'm not 100% familiar with how FAT32 manages disk space but I find it unlikely that it would record an application-specific, OS-specific, sorting choice. And even less likely that a standalone device which does not run the same OS would recognize and respect such a choice.

Any ideas on this?!?
tom66:
Windows is fond of putting a hidden folder on USB storage volumes called "System Volume Information".  Within it is a file known as 'WPSettings.dat', which is undocumented.  However, if this file is used to store the sorting information and somehow, your TV can also read this file, it could explain the behaviour.

You can delete the SVI folder if you show hidden files on exFAT/FAT32.  Can't be deleted on NTFS. 

Who makes the screens?  Are they Android based or just a generic flatscreen TV OS?  Android has implemented a lot of the idiosyncrasies supported by exFAT and FAT32 into it, perhaps this is one of them!
IDEngineer:
I have Explorer configured to display everything. System Volume Information is visible on some of my USB sticks, but not on those used for this application. As I said, I'm careful to keep these sticks totally empty except for the .JPG's.

The screens are very old plasma displays dating from ~2006-2007. They have a single USB port, no Ethernet interface, etc. Whatever code they're using cannot accommodate more than 2GB of data on the stick... the stick can have greater capacity but if it has more than 2GB of data the screen can only "see" a limited number of the photos and fails to display the rest. Feels like address space wrapping. (The limit seems based on total active memory, not on file count.) My point is these are old screens with very limited processing power. I seriously doubt they are running any form of formal OS and likely just have some sort of dedicated embedded firmware.
CatalinaWOW:
It sounds like Windows writes the files in the current sort order.  Since you are writing into a completely erased thumb there is no reason to expect them to be in a different order.  The TV just reads them back in sequence.

This could be an advantage if you used one of the other standard attributes (track number seems like an obvious choice) as a sequence number which would give you complete freedom in ordering (at the cost of a lot of tedium assigning track numbers).

I would also guess that your old TV assumes FAT32 with 32K sectors. 
edavid:

--- Quote from: CatalinaWOW on December 15, 2021, 06:43:47 pm ---It sounds like Windows writes the files in the current sort order.  Since you are writing into a completely erased thumb there is no reason to expect them to be in a different order.  The TV just reads them back in sequence.

--- End quote ---

He is not rewriting the files after changing the sort order, but the TV display order still changes.

My guess is that Explorer is changing one of the time stamps, but I don't know why that would happen.

I would try to figure out what's happening with the FileActivityWatch utility:

https://www.nirsoft.net/utils/file_activity_watch.html
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod