Importing photos from smartphone - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Importing photos from smartphone (/thread-2982.html) |
Importing photos from smartphone - Robinbux - Apr-22-2017 Hi, I want my script to import photos from my smartphone, to the raspberry pi. My code looks like this: import glob, shutil source = "mtp://[usb:001,025]/Phone/Pictures/Ballons" and "mtp://[usb:001,025]/Phone/Pictures/Familie" and "mtp://[usb:001,025]/Phone/Pictures/Florida" and "mtp://[usb:001,025]/Phone/Pictures/Ramona" and "mtp://[usb:001,025]/Phone/Pictures/Screenshots" dest = "/home/pi/Desktop/Photos" for file in glob.glob(source + "/*.jpg"): shutil.copy(file, dest)I don't see any problem in it, but when I run it nothing happens. Does anyone have an idea what I did wrong? RE: Importing photos from smartphone - volcano63 - Apr-23-2017 See this answer. and ing strings, you end up with source having the last value in your expression.You have to place your URLs into a list and iterate over all locations - or just use os.walk() for loc, _, files in os.walk('mtp://[usb:001,025]/Phone/Pictures'): for file_name in files: if file_name.endswith('jpg'): shutil.copy(os.path.join(loc, file_name), dest) RE: Importing photos from smartphone - nilamo - Apr-29-2017 (Apr-23-2017, 07:34 PM)volcano63 Wrote: See this answer. Evidence: >>> files = "left" and "middle" and "right" >>> files 'right' |