Python Forum
Compare filename with folder name and copy matching files into a particular folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compare filename with folder name and copy matching files into a particular folder
#2
Well, offcourse there will be a better way or at least a different way. But I think I would be helpfull to organize your code a little first. I'm sure your code will work eventually, but putting al those actions, if statements etc. in just one script makes it hard to read, but more important it makes it hard to add new code.

For example, the loops you use for searches in folders could be a function that returns a value such as True or False. The function will be reusable as many times you want, no matter how many folders you want to search.

I do realize this is not a perfect answer to your question. But it is quite difficult to do suggestion for your code without having to rewrite it from the start. Working with smaller pieces of code will help to do suggestions.
- Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid. Albert Einstein
Reply


Messages In This Thread
RE: Compare filename with folder name and copy matching files into a particular folder - by Jeff900 - Dec-18-2021, 11:44 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 330 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  Deleting Windows temp folder Raysz 7 592 Apr-02-2024, 12:36 PM
Last Post: Raysz
  Help with creating folder and "virtual environment" AudunNilsen 1 280 Mar-21-2024, 04:41 AM
Last Post: deanhystad
Question How to add Python folder in Windows Registry ? Touktouk 1 334 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Copy Paste excel files based on the first letters of the file name Viento 2 505 Feb-07-2024, 12:24 PM
Last Post: Viento
  Create dual folder on different path/drive based on the date agmoraojr 2 515 Jan-21-2024, 10:02 AM
Last Post: snippsat
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 641 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  problem in import module from other folder akbarza 5 1,590 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  Reading a file name fron a folder on my desktop Fiona 4 1,005 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  Rename files in a folder named using windows explorer hitoxman 3 804 Aug-02-2023, 04:08 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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