[Tutor] read cell phone's directory?
= Clayton - Tang =
ctny at ctny.org
Thu Aug 14 04:07:58 CEST 2014
Hi all,
I am on WIndows and have an Android cell phone running Android 4.4.4.
When I connect the phone to my PC using a micro-USB cable, the phone appears
next to the local hard drive under "This PC" window, then I can browse the
phone's directory like a regular disk. My goal is to find all the photos on the
phone then do something with the files. So I copied the path from the File
Explore navigation bar, which is 'This PC\Nexus 5\Internal storage\DCIM\Camera',
but the follow code doesn't work.
I get an error "W indowsError: [Error 3] The system cannot find the path
specified: 'This PC\\Nexus 5\\Internal storage\\DCIM\\Camera/*.*". Does anyone
know who to make it work?
import os;
## Example pulls filenames from a dir, prints their relative and absolute paths
def printdir(dir):
filenames = os.listdir(dir)
for filename in filenames:
print filename ## foo.txt
print os.path.join(dir, filename) ## dir/foo.txt (relative to current dir)
print os.path.abspath(os.path.join(dir, filename)) ## /home/nick/dir/foo.txt
print
if __name__ == '__main__':
printdir('This PC\Nexus 5\Internal storage\DCIM\Camera')
Clayton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140813/0a162ff4/attachment.html>
More information about the Tutor
mailing list