Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copying a file
#1
import shutil
shutil.copy(“\\Om-pc\e\Office File\Access Original 14-16\Cash MAR.2017 TO APR.2019.accdb”, "C:\Users\KUNDAN\Desktop\Cash MAR.2017 TO APR.2019.accdb ")
The above code is giving the following error:
Traceback (most recent call last):
File "C:\Users\KUNDAN\backup.py", line 2
shutil.copy(“\\Om-pc\e\Office File\Access Original 14-16\Cash MAR.2017 TO APR.2019.accdb”, "C:\Users\KUNDAN\Desktop\Cash MAR.2017 TO APR.2019.accdb ")
^
SyntaxError: invalid character in identifier
Reply
#2
Use Code tag.
You are mixing left double quotation mark with ordinary quotation mark.
Next error will be here C:\U,do not use single backslash \ in path because of escape character.

Fixed it would be like this.
import shutil

shutil.copy("\\Om-pc\e\Office File\Access Original 14-16\Cash MAR.2017 TO APR.2019.accdb", r"C:\Users\KUNDAN\Desktop\Cash MAR.2017 TO APR.2019.accdb")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help copying a column from a csv to another file with some extras g0nz0uk 3 403 Feb-01-2024, 03:12 PM
Last Post: DeaD_EyE
  How To Find an Opening and Closing String, Copying Open/Close/Contents to New File davidshq 1 1,988 Mar-03-2020, 04:47 AM
Last Post: davidshq
  Copying XML elements from one file to another kirat 2 6,471 Sep-05-2019, 04:37 AM
Last Post: buran

Forum Jump:

User Panel Messages

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