Python Forum
Copy and Paste Files - Command
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy and Paste Files - Command
#1
Good night people,
I have a problem, I used the following code to copy and paste files from one folder to another
import os
import time
import shutil

origem = r"C:\Program Files\Corel\CorelDRAW Graphics Suite 2022\Programs64\Pasta2"
destino = r"C:\Program Files\Corel\CorelDRAW Graphics Suite 2022\Programs64\Pasta1"

def copy_files(origem, destino):
    os.makedirs(destino, exist_ok=True)
    for item in os.listdir(origem):
        origem_arquivo = os.path.join(origem, item)
        destino_arquivo = os.path.join(destino, item)
        if os.path.isfile(origem_arquivo):
            shutil.copy2(origem_arquivo, destino_arquivo)

copy_files(origem, destino)
but it started giving an error that I don't have permission

It started out of nowhere, it always worked, but now this error has started.
I haven't changed anything on my computer
Could you help me find why? Thanks
Reply
#2
PermissionError: [Errno 13] Permission denied: 'C:\\Program Files\\Corel\\CorelDRAW Graphics Suite 2022\\Programs64\..... I discovered that if I open VisualStudio with the right button and run it as administrator, this program works fine. The strange thing is that it was a .py file and it always worked, out of nowhere this afternoon this bug started
Reply
#3
One thing is sure, permission errors are not usually related to python. You may want to learn how to check file/folders owners and permissions on your system. Spot the file/folder which causes troubles and carefully examine who is the owner and what permissions there are.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 448 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Copy Paste excel files based on the first letters of the file name Viento 2 631 Feb-07-2024, 12:24 PM
Last Post: Viento
  What script to paste folders thenewcoder 1 801 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 2,402 Jun-06-2023, 05:49 PM
Last Post: rajeshgk
  Create new folders and copy files cocobolli 3 1,794 Mar-22-2023, 10:23 AM
Last Post: Gribouillis
  Copy only hidden files and folders with rsync Cannondale 2 1,215 Mar-04-2023, 02:48 PM
Last Post: Cannondale
  Please help me [copy and paste file from src to dst] midomarc 2 1,152 Nov-24-2022, 10:13 PM
Last Post: midomarc
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,793 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  ImageTk Paste KDog 14 7,445 Jun-27-2021, 11:07 AM
Last Post: KDog
  Cut and Paste Oshadha 3 2,636 Jan-20-2021, 04:27 PM
Last Post: spaceraiders

Forum Jump:

User Panel Messages

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