Python Forum
transfering photos and videos
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
transfering photos and videos
#1
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!
Reply
#2
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)
Reply
#3
Thanks nilamo, that worked!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to import in photos CoderX 2 1,026 Jan-17-2024, 07:00 PM
Last Post: deanhystad
  PyCharm Tutorial Links/Videos For Absolute Beginner? pyJim 3 5,180 Jan-24-2017, 10:40 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020