I am a completely novice programmer, and therefore even the simplest tasks cause a lot of questions to me. So please help me :(
I need a small python script that will pop up "reports" with straightforward names (Forma_T1_1-140100013467-17.09.2018-11_52_50.xls) from the "TEST1 / Reports /" folder in the "TEST1 / Reports Отчет / НМУПТТ", "TEST1 / Reports" folders / CTU ", ..." TEST1 / ReportsY / n "; where in the file name after "Forma_T1_1-" there is a four-digit index.
How to explain so as not to confuse yourself. Suppose that these 4 numbers = 1401 (as in the example file), then you need to drop this file into the folder "TEST1 / Reports L / NMUPTT", and if there were 1023 - then into the folder "TEST1 / Reports L / CTU".
Here is my "miracle" of thought:
(so far it only initiates files, and I commented out the transfer function because it is temporarily useless)
import os import shutil #C:\Users\Admin\Desktop\TEST1\ #C:\Users\Admin\Desktop\TEST1\ОтчетыЖ\НМУПТТ #C:\Users\Admin\Desktop\TEST1\ОтчетыЖ\ЧТУ count = 0 main_folder = os.listdir('../TEST1')#файлы в папке folder2 = os.listdir(main_folder[1])#файлы в 2-ой папки folder3 = os.listdir(main_folder[2])#файлы в 3-ей папки files_list = len(os.listdir(main_folder[1])) def check(): files_dir = os.path.abspath(folder2[count]) print('файлов в папке = ', files_list) print('файл №', count+1, '=', folder2[count]) print(files_dir) def replace(): files_dir = os.path.abspath(folder2[count]) file_name = folder3[count] if file_name == '210015.txt': shutil.move('folder2/'+file_name, 'folder3/') while count<files_list: check() #replace() count = count + 1 Whatever my brain disease progresses, please tell me what I'm doing wrong and how to solve this problem correctly