I'm hoping this is a very simple issue with a simple solution.
I have a raspberry pi and an external hard drive that I am writing data to. I would like to know if there is a way in python, to programmatically determine the name of a connected drive in order to switch to the proper directory.
Right now my program is hard coded, but I would like to have the pi determine the name of the drive in order to account for the drives name possibly getting changed (which has already happened).
The drive always appears in the /media/pi directory. My solution right now is to just fetch the names in that directory, disregard certain folders already there, then assign my drive variable to the (hopefully) only remaining one. I don't like this idea but its my only one right now.
Does the community have a more robust solution to my problem? If so how should I go about doing this?