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


Messages In This Thread
Copy and Paste Files - Command - by MicheliBarcello - Jun-24-2024, 10:33 PM
RE: Copy and Paste Files - Command - by rodiongork - Jun-25-2024, 05:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 453 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Copy Paste excel files based on the first letters of the file name Viento 2 636 Feb-07-2024, 12:24 PM
Last Post: Viento
  What script to paste folders thenewcoder 1 809 Nov-29-2023, 09:40 AM
Last Post: Pedroski55
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 2,414 Jun-06-2023, 05:49 PM
Last Post: rajeshgk
  Create new folders and copy files cocobolli 3 1,810 Mar-22-2023, 10:23 AM
Last Post: Gribouillis
  Copy only hidden files and folders with rsync Cannondale 2 1,225 Mar-04-2023, 02:48 PM
Last Post: Cannondale
  Please help me [copy and paste file from src to dst] midomarc 2 1,153 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,802 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  ImageTk Paste KDog 14 7,453 Jun-27-2021, 11:07 AM
Last Post: KDog
  Cut and Paste Oshadha 3 2,639 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