1

I'm looking for something on Windows that can help manage the content of several removable drives, particularly overwriting and pushing new files onto them in different combinations from a similar pool on content. As it stands, Windows Explorer is quite slow to do this and the process is quite tedious when you have a large number of drives.

For context, we have a series of of public advertisement screens playing at a range of locations, each of which runs content off of a USB drive that has to remain connected to the device. Each of these displays a series of commercials in different combinations. Most of these are broken up into regions so similarly-located screens are playing the same content. Some ads play in multiple regions as well.

At the moment, what this means is that when we want to update them, I have to get a big spreadsheet from the sales reps outlining which screens are showing which ads. Then I essentially have to pick out the ad content files and manually create master folder of each region which I then paste over the files that are on the drive.

Windows Explorer is quite slow in doing this and will not always correctly overwrite files if I paste it to too many drives at once.

  • I am guessing there is no internet access, which is why you use USB. In a similar situaiton, I used Wifi (with wifi enbled Linux devices costing $10 these days) and loaded content from a custom Android app, which communicted via WiFi. Too late for your currnt project, but bear it in mind for the next one. – Mawg Sep 8 '16 at 9:09
  • You're not going to get very far without actually programming, I'm afraid. Steve's answer is a good approach to start with, but if you don't have programming expertise, outsource this. And it does not help that this information is in an Excel sheet, a database would be much smarter (but then you'd also have to program something for its data entry, so I get why the organization chose the lazy way of using a spreadsheet). – Jan Doggen Sep 9 '16 at 12:06
1

Personally I would give the following a try:

  1. Install python and the library xlrd once python is installed you can do this with pip install xlrd.
  2. On each USB stick have a file that uniquely identifies that stick and another that lists the files and their MD5 values, (we will get to why a little further on), currently on the stick
  3. In the spreadsheet, assuming that it is organised with one column for each location and one row for each item, have a, possibly hidden, row that gives the same identifiers as the USB sticks have.
  4. In the spreadsheet have a second sheet that lists the sources for the content, again each with a unique identifier the origin path, the destination path and the MD5 of the original file.
  5. Make sure that the unique identifiers match those in a, possibly hidden, column on the spreadsheet.
  6. Write a little python script to:
    1. Get the date/time on the Excel spreadsheet file,
    2. parse the spreadsheet page 2 into a dictionary of the unique media identifiers to their MD5, origin & target locations plus
    3. to parse page 1 into a dictionary of the unique USB identifiers to the unique media identifiers that are required, i.e. those that have True/Yes/1 for that media item in the column for that USB device.
    4. Save all 3 data structures into a pickle file for later use.
  7. Write another python script to read the spreadsheet file date/time from both the pickle file and the spreadsheet and if they don't match to call your first script and then re-read the pickle file this will make sure that your data is current & correct.
  8. You second script should then run through a list of potential USB locations, (typically E:, F:, etc. on Windows), looking for the file with the USB drive identifier in and for each that it finds one it can launch a separate thread/process, see multiprocessing, to:
    1. read the current contents file,
    2. compare it to the dictionary entry for that USB drive,
    3. delete any files on the USB drive that are either not in the dictionary entry, or have the wrong MD5 value - this value is used so that file which have been updated but not renamed will get replaced and then
    4. copy to the USB drive the files that were missing or have a different MD5 value.
    5. Finally it should re-write the contents file to the USB drive.

Note I have assumed that your spreadsheet is organised in columns for each location, (i.e. USB device), and rows for each media item but obviously you could swap these around if your spreadsheet is organised otherwise.

An experience python programmer could probably knock this up in an hour or so but, with the steps above, a total beginner should be able to manage it in a day.

Using multiprocessing means that up to the number of cores your machine has available can be used at once, one for each USB found. Deleting the mismatched MD5 files first, at the same time as the no longer required files, ensures that fresh copies are installed but maintaining a list of the current content on the drive will minimise the operations that need to be performed and make the process as fast as possible.

You will probably also wish to have a create_usb script which will take the drive letter that a new USB is connected to and a new, (or reused if one of the current devices has been lost or damaged), unique USB ID and then:

  1. formats the device
  2. creates the identifier file plus a blank table of contents
  3. Invokes the same process as above to populate the contents.

Python & the xlrd library are Free, Gratis & Open Source. Both are cross platform and do not need a copy of Excel to work.

Once you have the above scripts you could even consider putting the excel spreadsheet and media content onto a network drive and connecting some Raspberry Pi 2/3 devices, to the same network. The Raspberry Pi is very reasonably priced and has a network connection plus 4 USB ports so each device could handle several drives at once. You python script with a couple of minor changes, (USB drives do not have letters under Raspbian, the network drive would have to be accessed plus I would suggest that if all jobs are done it should wait a short time then re-scan the potential drives), would then be able to do the job unattended possibly sending out a mail when all/each connected drives has been done or using the GPIO to light an LED for each socket when done. This would probably be slower for each individual drive but given the price of them, (currently about £40/$50), for a starter kit with a card, case, PSU & uSD card with the OS and cables or you can stack them), you could massively parallel your process. The case below would stack 4 Raspberry Pi boards potentially giving 16 sticks being written at once for under $300 outlay. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.