Advertisement
Danila_lipatov

copy_to_dir

Nov 27th, 2023 (edited)
609
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import os
  2. import shutil
  3.  
  4. """
  5. A primitive file copier from an array.
  6. An array of necessary files is passed, a directory for searching, a directory where to copy.
  7. In the case of an undefined format, add conditions.
  8. """
  9.  
  10. if __name__ == '__main__':
  11.     excel_arr = []
  12.     current_dir = ''
  13.     new_dir = ''
  14.     for root, dirs, files in os.walk(current_dir):
  15.         for file in files:
  16.             for excel in excel_arr:
  17.                 if excel in file:
  18.                     excel_path = str(os.path.join(root, file))
  19.                     shutil.copy(excel_path, new_dir)
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement