Python Forum

Full Version: transfering photos and videos
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, for a school project I want to build a USB stick, which automaticly transfers photos and videos to the stick, if plugged in.
I use Portableapps and now want to write a Python program on the stick, which does that.
By now, I'm a total noob, so I'm sorry if I'm asking something very easy, but I actually couldn't find it on google.
My code by now: 

newpath = r'D:\Program Files\Photos and videos'
from /storage/emulated/0/Download import xxx to 'D:\Program Files\Photos and videos'
from /storage/emulated/0/Camera import xxx to 'D:\Program Files\Photos and videos'
from /storage/emulated/0/Screenshots import xxx to 'D:\Program Files\Photos and videos'
My problem is, that I don't knoow how to tell python, that it shall import all the files.
I know how I could import specific ones with their names, but not simply everything.
Is there a way to do so?
And except for this, is my code ok like this?

Thanks for all help!
If they're photos, then "import" would not do what you expect.  import only loads other python files.

The easiest way to do this would probably be to use glob to find files, and shutil to copy them.

Something like...
import glob, shutil

source = "/storage/emulated/0/"
dest = "d:/Programe Files/Photos and videos/"

for file in glob.glob(source + ".jpg"):
   shutil.copy(file, dest)
Thanks nilamo, that worked!