1

I am very new to Python. I am curious to how I would be able to copy some files from my directory to another Users directory on my computer using python script? And would I be correct in saying I need to check the permissions of the users and files? So my question is how do I send files and also check the permissions at the same time

1
  • You can try it, though it might fail. But you can write code to handle the failures. Commented Sep 23, 2016 at 16:32

2 Answers 2

2

You want to use shutil.copy(src, destination), you can find the docs here: https://docs.python.org/2/library/shutil.html#shutil.copy

You can also read here on how to access file permissions in python: Checking File Permissions in Linux with Python

Determining Whether a Directory is Writeable

Sign up to request clarification or add additional context in comments.

Comments

1

shutil is a very usefull thing to use when copying files. I once needed to have a python script that moved all .mp3 files from a directory to a backup, deleted the original directory, created a new once, and moved the .mp3 files back in. shutil was perfect for thise.

The formatting for the command is how @Kieran has stated earlier.

If you're looking to keep file metadata, then use shutil.copy2(src, dest), as that is the equivalent of running copy() and copystat() one after another.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.