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
Asked
Active
Viewed 891 times
2 Answers
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
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.

RedXTech
- 406
- 2
- 7
- 17