Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Пользователь с клавиатуры вводит путь к существующей директории и к новой директории. После чего
- запускается поток, который должен скопировать содержимое директории в новое место. Необходимо сохранить
- структуру директории. На экран необходимо отобразить
- статистику выполненных операций.
- """
- import threading
- import os
- import shutil
- current_directory = input("Введите путь к существующей директории: ").replace("\"", "")
- new_directory = input("Введите путь к новой директории: ").replace("\"", "")
- def copy_directory(src, dst):
- if not os.path.exists(dst):
- os.makedirs(dst)
- for item in os.listdir(src):
- current_item = os.path.join(src, item)
- new_item = os.path.join(dst, item)
- if os.path.isdir(current_item):
- copy_directory(current_item, new_item)
- else:
- shutil.copy2(current_item, new_item)
- if not os.path.exists(current_directory):
- print(f"Директория {current_directory} не существует!")
- else:
- thread = threading.Thread(target=copy_directory, args=[current_directory, new_directory])
- thread.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement