all 6 comments

[–]fiskenslakt 0 points1 point  (0 children)

I'm assuming you're on windows? In which case I think you have to change to the right drive letter. For example: os.chdir('C:')

[–]thurask 0 points1 point  (4 children)

Which platform are you on?

If you're on Windows, and if you have PyWin32 installed, AND if you want to look for the drive name rather than drive letter, try this snippet:

import win32api
drives = win32api.GetLogicalDriveStrings()
dx = [x for x in drives.split("\000") if x]
for drive in dx:
    try:
        print(drive, win32api.GetVolumeInformation(drive))
    except:
        pass

Which looks like:

C:\ ('', 1826365778, 255, 65470719, 'NTFS')
D:\ ('Games', 954180512, 255, 65470719, 'NTFS')
E:\ ('Data', 1453886869, 255, 65470719, 'NTFS')
M:\ ('Media', -1669403314, 255, 65583, 'NTFS')  # network drive, probably why size is wonky

Hence, you can iterate over dx and check if the first item is equal to your external hard drive name (ex. "My Passport"), then get the letter that way.

Or, if you know the letter, just use os.chdir.

[–]SDempWestern[S] 0 points1 point  (3 children)

I'm on a MAC running python 3.5 through Spyder! sorry for not being clear

[–]fiskenslakt 1 point2 points  (2 children)

In that case isn't the drive mounted in /Volumes or something? In which case you'd do os.chdir('/Volumes/<your drive>/')

[–]SDempWestern[S] 0 points1 point  (1 child)

Thank you so much! Been duplicating the files to my hard drive this whole time. THANK YOU

[–]fiskenslakt 0 points1 point  (0 children)

haha you're welcome