Python Forum
Shutil FileNotFoundError: Errno 2 Help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shutil FileNotFoundError: Errno 2 Help
#6
Maybe I don't understand the problem, but I thought you have a file containing filenames.
Quote:name1
name2
name3
And you also have file containing file paths.
Quote:path1
path2
path3
And that you want to use the names and paths to copy files from a source folder to different destination folders.
Quote:copy source_dir/name1 to path1/name1
copy source_dir/name2 to path2/name2
copy source_dir/name3 to path3/name3
If this is correct I see no reason for two loops. In one loop you could read the filename, read the desination directory and dp tje file copy (or rename).

I suppose you could use two loops. A loop to read all the file names and then a second loop to read the destination directory and do the copy. These loops would be one after the other, not one nested inside another. Heck, you could use three loops if you wanted; read names, read paths, do copy/rename. But why use 2 or 3 loops when one loop is faster and makes the most sense. One loop with a series of tasks that are performed for each loop iteration.
Reply


Messages In This Thread
RE: Shutil FileNotFoundError: Errno 2 Help - by deanhystad - Aug-09-2020, 04:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 7 3,487 Mar-09-2025, 04:25 PM
Last Post: Pedroski55
  FileNotFoundError: [Errno 2] No such file or directory although the file exists Arnibandyo 0 1,106 Aug-12-2024, 09:11 AM
Last Post: Arnibandyo
  use of shutil.copytree with ENOTDIR exception yan 2 2,888 Nov-29-2023, 03:02 PM
Last Post: yan
  shutil.move make data corrupt kucingkembar 0 1,602 Feb-01-2023, 01:30 PM
Last Post: kucingkembar
  Need Help: FileNotFoundError:[Errno 2] No such file or directory python202209 5 6,230 Sep-12-2022, 04:50 AM
Last Post: python202209
  FileNotFoundError: [Errno 2] No such file or directory: 'word2vec.model' Anldra12 6 8,212 Jul-07-2021, 07:29 AM
Last Post: Anldra12
  FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles Anldra12 10 9,465 Jun-11-2021, 04:48 PM
Last Post: snippsat
  extra slashes in the network path for shutil.copy tester_V 3 5,255 Jun-02-2021, 07:57 AM
Last Post: supuflounder
  concatenat - shutil jmabrito 3 3,021 Feb-11-2021, 12:17 PM
Last Post: jmabrito
  FileNotFoundError: [Errno 2] No such file or directory: 5l3y3r 6 10,592 Nov-02-2020, 12:48 PM
Last Post: 5l3y3r

Forum Jump:

User Panel Messages

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