0

I was using the code shutil.copyfile(src_file, dst_file) to copy the source file into the target destination. However, the path is apparently too long, so I got the error 'FileNotFoundError: [Errno 2] No such file or directory: .\\Merged\\Book\\Book123\\New\\library\\helloworld\\ass\\data\\explore_the_world\\explore_content\\sassy_pane\\conditional_testing\\formatting_life_session\\locales\\en\\conditional_fformatting_life_session_component_new.strings.json'

I think the double slash was built into the Python file path interpretation, so I can't just change it from my script.. I've read the method of adding u(\\\\?\) to the file path, such as shutil.copyfile(u"\\\\?\\" + src_file, u"\\\\?\\" + dst_file), but it doesn't work.. I'll get an error of 'FileNotFoundError: [Errno 2] No such file or directory: \\\\?\\.\\Merged\\Book\\Book123\\New\\library\\helloworld\\ass\\data\\explore_the_world\\explore_content\\sassy_pane\\conditional_testing\\formatting_life_session\\locales\\en\\conditional_fformatting_life_session_component_new.strings.json'

I've read this article, but it doesn't really help solve my issue..Could anybody enlighten me over this? Thank you!! Python: copy long file path Shutil.copyfile

Penny
  • 1,218
  • 1
  • 13
  • 32

0 Answers0